/
build.go
43 lines (38 loc) · 1001 Bytes
/
build.go
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
43
package vendor
import (
"expvar"
)
// These vendor package level variables are here to allow build script to
// modify them via:
// go install -ldflags \
// '-X github.com/weingart/vendor.buildUser ${USER}' \
// ...
// These are all strings and default to "".
var (
buildSHA string = "" // SHA (or build revision)
buildTag string = "" // Tag of this build
buildUser string = "" // User that built the artifact
buildTime string = "" // Unix time since EPOCH (string, in seconds)
buildComment string = "" // Random comment
)
type BuildInfo struct {
SHA string `json:"sha"`
Tag string `json:"tag"`
User string `json:"user"`
Time string `json:"time"`
Comment string `json:"comment"`
}
func GetBuildInfo() *BuildInfo {
return &BuildInfo{
SHA: buildSHA,
Tag: buildTag,
User: buildUser,
Time: buildTime,
Comment: buildComment,
}
}
func init() {
expvar.Publish("build", expvar.Func(func() interface{} {
return GetBuildInfo()
}))
}