We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dd871c8 commit ba97af9Copy full SHA for ba97af9
1 file changed
version.go
@@ -16,6 +16,29 @@
16
17
package main
18
19
-const (
20
- Version = "0.2.1"
+import (
+ "debug/buildinfo"
21
+ "fmt"
22
+ "os"
23
)
24
+
25
+var Version = "0.0.0"
26
27
+func init() {
28
+ path, err := os.Executable()
29
+ if err != nil {
30
+ fmt.Fprintf(os.Stderr, "fail to get executable path: %v\n", err)
31
+ return
32
+ }
33
+ data, err := os.Open(path)
34
35
+ fmt.Fprintf(os.Stderr, "fail to read executable file: %v\n", err)
36
37
38
+ info, err := buildinfo.Read(data)
39
40
+ fmt.Fprintf(os.Stderr, "fail to read build info: %v\n", err)
41
42
43
+ Version = info.Main.Version
44
+}
0 commit comments