-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathversion.go
53 lines (47 loc) · 1.06 KB
/
version.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
50
51
52
53
package main
import (
"bytes"
"fmt"
)
// Program version information
var (
buildArch string
buildBranch string
buildCompiler string
buildDate string
buildHash string
buildUser string
buildVersion string
)
type versionInfo struct {
Arch string
Branch string
Compiler string
Date string
Hash string
User string
Version string
// Non static
Pid int
Uptime string
}
func (vi versionInfo) String() string {
var buffer bytes.Buffer
buffer.WriteString(fmt.Sprintf("Version:\t%s\n", vi.Version))
buffer.WriteString(fmt.Sprintf("Build time:\t%s\n", vi.Date))
buffer.WriteString(fmt.Sprintf("Build:\t\t%s@%s:%s\n", vi.User, vi.Branch, vi.Hash))
buffer.WriteString(fmt.Sprintf("Compiler:\t%s\n", vi.Compiler))
buffer.WriteString(fmt.Sprintf("Arch:\t\t%s\n", vi.Arch))
return buffer.String()
}
func getVersionInfo() versionInfo {
return versionInfo{
Arch: buildArch,
Branch: buildBranch,
Compiler: buildCompiler,
Hash: buildHash,
Date: buildDate,
User: buildUser,
Version: buildVersion,
}
}