-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.go
49 lines (41 loc) · 948 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
44
45
46
47
48
49
package cli
import (
"runtime"
"time"
)
// AppName is the name of the CLI application.
const AppName = "tmpl"
// Build information set by the compiler.
var (
buildVersion = "0.0.0-dev"
buildCommit = "HEAD"
buildTime = ""
buildGoVersion = runtime.Version()
)
// Version of tmpl.
//
// Returns `0.0.0-dev` if no version is set.
func Version() string {
return buildVersion
}
// BuildCommit returns the git commit hash tmpl was built from.
//
// Returns `HEAD` if no build commit is set.
func BuildCommit() string {
return buildCommit
}
// BuildTime returns the UTC time tmpl was built.
//
// Returns current time in UTC if not set.
func BuildTime() string {
if buildTime == "" {
return time.Now().UTC().Format(time.RFC3339)
}
return buildTime
}
// BuildGoVersion returns the go version tmpl was built with.
//
// Returns version from [runtime.Version] if not set.
func BuildGoVersion() string {
return buildGoVersion
}