File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 "console" : " integratedTerminal" ,
2424 "hideSystemGoroutines" : true ,
2525 "buildFlags" : [
26- " -ldflags=-X github.com/toeirei/keymaster/buildvars.Version=development "
26+ " -ldflags=-X github.com/toeirei/keymaster/buildvars.Version=dev "
2727 ]
2828 },
2929 {
Original file line number Diff line number Diff line change 55// Package buildvars contains variables injected at build time.
66package buildvars
77
8+ import (
9+ "runtime/debug"
10+ )
11+
812// Version is set at link time via `-ldflags -X github.com/toeirei/keymaster/buildvars.Version=...`.
9- var Version string = "unknown version"
13+ var Version string
14+
15+ func init () {
16+ if Version == "" {
17+ Version = "unknown"
18+
19+ if buildInfo , ok := debug .ReadBuildInfo (); ok {
20+ var vcs , vcsRevision , vcsModified string
21+ for _ , setting := range buildInfo .Settings {
22+ switch setting .Key {
23+ case "vcs" :
24+ vcs = setting .Value
25+ case "vcs.revision" :
26+ vcsRevision = setting .Value
27+ case "vcs.modified" :
28+ vcsModified = setting .Value
29+ }
30+ }
31+
32+ if vcs != "" && vcsRevision != "" {
33+ if vcs == "git" {
34+ vcsRevision = vcsRevision [:7 ]
35+ }
36+
37+ Version = vcs + ":" + vcsRevision
38+
39+ if vcsModified == "true" {
40+ Version += "*"
41+ }
42+ }
43+ }
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments