Skip to content

Commit 00a2aef

Browse files
committed
Build statically and add build information
1 parent 0a7e7fd commit 00a2aef

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

cmd/youtubedr/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/http"
1212
"os"
1313
"os/exec"
14+
"runtime"
1415
"strconv"
1516
"time"
1617

@@ -31,6 +32,12 @@ var (
3132
itag int
3233
info bool
3334
insecureSkipVerify bool
35+
showVersion bool
36+
37+
// set through ldflags
38+
version string
39+
commit string
40+
date string
3441
)
3542

3643
func main() {
@@ -52,10 +59,19 @@ func run() error {
5259
flag.StringVar(&outputQuality, "q", "", "The output file quality (hd720, medium)")
5360
flag.IntVar(&itag, "i", 0, "Specify itag number, e.g. 13, 17")
5461
flag.BoolVar(&info, "info", false, "show info of video")
62+
flag.BoolVar(&showVersion, "version", false, "show version info and exit")
5563
flag.BoolVar(&insecureSkipVerify, "insecure-skip-tls-verify", false, "skip server certificate verification")
5664

5765
flag.Parse()
5866

67+
if showVersion {
68+
fmt.Println("Version: ", version)
69+
fmt.Println("Commit: ", commit)
70+
fmt.Println("Date: ", date)
71+
fmt.Println("Go Version: ", runtime.Version())
72+
os.Exit(0)
73+
}
74+
5975
if len(flag.Args()) == 0 {
6076
flag.Usage()
6177
return nil

goreleaser.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ builds:
99
goarch:
1010
- amd64
1111
- arm
12+
- arm64
13+
flags:
14+
- -trimpath
15+
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.CommitDate}} -linkmode external -extldflags "-static"

0 commit comments

Comments
 (0)