/
version.go
44 lines (39 loc) · 1.11 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
// Package params provides common version info and config items.
package params
import (
"fmt"
)
// version parts
const (
VersionMajor = 3 // Major version component of the current release
VersionMinor = 6 // Minor version component of the current release
VersionPatch = 2 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)
// Version holds the textual version string.
var Version = func() string {
return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}()
// VersionWithMeta holds the textual version string including the metadata.
var VersionWithMeta = func() string {
v := Version
if VersionMeta != "" {
v += "-" + VersionMeta
}
return v
}()
// VersionWithCommit add git commit and data to version.
func VersionWithCommit(gitCommit, gitDate string) string {
vsn := Version
if VersionMeta != "" {
vsn += "-" + VersionMeta
}
if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8]
}
if (VersionMeta != "stable") && (gitDate != "") {
vsn += "-" + gitDate
}
VersionWithMeta = vsn // update if more concrete
return vsn
}