forked from hashicorp/consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
41 lines (35 loc) · 896 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
package version
import (
"fmt"
"strings"
)
var (
// The git commit that was compiled. These will be filled in by the
// compiler.
GitCommit string
GitDescribe string
// Release versions of the build. These will be filled in by one of the
// build tag-specific files.
Version = "unknown"
VersionPrerelease = "unknown"
)
// GetHumanVersion composes the parts of the version in a way that's suitable
// for displaying to humans.
func GetHumanVersion() string {
version := Version
if GitDescribe != "" {
version = GitDescribe
}
release := VersionPrerelease
if GitDescribe == "" && release == "" {
release = "dev"
}
if release != "" {
version += fmt.Sprintf("-%s", release)
if GitCommit != "" {
version += fmt.Sprintf(" (%s)", GitCommit)
}
}
// Strip off any single quotes added by the git information.
return strings.Replace(version, "'", "", -1)
}