-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_info.go
More file actions
42 lines (35 loc) · 652 Bytes
/
build_info.go
File metadata and controls
42 lines (35 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package worker
import (
"runtime"
"runtime/debug"
)
type buildInfo struct {
Version string
Commit string
BuildTime string
GoVersion string
}
func readBuildInfo() buildInfo {
info := buildInfo{
Version: "dev",
GoVersion: runtime.Version(),
}
build, ok := debug.ReadBuildInfo()
if !ok {
return info
}
if build.Main.Version != "" && build.Main.Version != "(devel)" {
info.Version = build.Main.Version
}
for _, setting := range build.Settings {
switch setting.Key {
case "vcs.revision":
info.Commit = setting.Value
case "vcs.time":
info.BuildTime = setting.Value
default:
continue
}
}
return info
}