forked from cosmos/cosmos-sdk
/
version.go
40 lines (35 loc) · 802 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
//nolint
package version
import (
"fmt"
"runtime"
)
// Variables set by build flags
var (
Commit = ""
Version = ""
VendorDirHash = ""
BuildTags = ""
)
type versionInfo struct {
CosmosSDK string `json:"cosmos_sdk"`
GitCommit string `json:"commit"`
VendorDirHash string `json:"vendor_hash"`
BuildTags string `json:"build_tags"`
GoVersion string `json:"go"`
}
func (v versionInfo) String() string {
return fmt.Sprintf(`cosmos-sdk: %s
git commit: %s
vendor hash: %s
build tags: %s
%s`, v.CosmosSDK, v.GitCommit, v.VendorDirHash, v.BuildTags, v.GoVersion)
}
func newVersionInfo() versionInfo {
return versionInfo{
Version,
Commit,
VendorDirHash,
BuildTags,
fmt.Sprintf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)}
}