-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_details.go
More file actions
51 lines (41 loc) · 1.25 KB
/
Copy pathbuild_details.go
File metadata and controls
51 lines (41 loc) · 1.25 KB
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
50
51
package oastools
import (
"fmt"
"runtime"
)
var (
// version is set via ldflags during build by GoReleaser
// For development builds, this will show "dev"
version = "dev"
// commit is the git commit hash, set via ldflags during build
// For development builds, this will show "unknown"
commit = "unknown"
// buildTime is the build timestamp in RFC3339 format, set via ldflags during build
// For development builds, this will show "unknown"
buildTime = "unknown"
)
// Version returns the compiled version or 'dev' if run from source
func Version() string {
return version
}
// Commit returns the git commit hash or 'unknown' if run from source
func Commit() string {
return commit
}
// BuildTime returns the build timestamp or 'unknown' if run from source
func BuildTime() string {
return buildTime
}
// GoVersion returns the Go version used to build the binary
func GoVersion() string {
return runtime.Version()
}
// UserAgent returns the User-Agent string to use
func UserAgent() string {
return fmt.Sprintf("oastools/%s", version)
}
// BuildInfo returns a formatted string with all build metadata
func BuildInfo() string {
return fmt.Sprintf("Version: %s\nCommit: %s\nBuild Time: %s\nGo Version: %s",
Version(), Commit(), BuildTime(), GoVersion())
}