forked from cubefs/cubefs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
54 lines (48 loc) · 958 Bytes
/
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
54
package proto
import (
"fmt"
"runtime"
)
var (
Version string
CommitID string
BranchName string
BuildTime string
)
func DumpVersion(role string) string {
return fmt.Sprintf("CubeFS %s\n"+
"Version : %s\n"+
"Branch : %s\n"+
"Commit : %s\n"+
"Build : %s %s %s %s\n",
role,
Version,
BranchName,
CommitID,
runtime.Version(), runtime.GOOS, runtime.GOARCH, BuildTime)
}
type VersionInfo struct {
Role string
Version string
Branch string
Commit string
Build string
}
func (v VersionInfo) ToMap() map[string]string {
return map[string]string{
"role": v.Role,
"version": v.Version,
"branch": v.Branch,
"commit": v.Commit,
"build": v.Build,
}
}
func GetVersion(role string) VersionInfo {
return VersionInfo{
Role: role,
Version: Version,
Branch: BranchName,
Commit: CommitID,
Build: fmt.Sprintf("%s %s %s %s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH, BuildTime),
}
}