forked from decred/dcrdata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
40 lines (32 loc) · 841 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
// Copyright (c) 2017, The dcrdata developers
// See LICENSE for details.
package api
import "fmt"
// APIVersion is an integer value, incremented for breaking changes
const APIVersion = 1
type version struct {
Major, Minor, Patch int
Label string
Nick string
}
var ver = version{
Major: 1,
Minor: 0,
Patch: 0,
Label: ""}
// CommitHash may be set on the build command line:
// go build -ldflags "-X main.CommitHash=`git rev-parse --short HEAD`"
var CommitHash string
const appName string = "dcrdata-api"
func (v *version) String() string {
var hashStr string
if CommitHash != "" {
hashStr = "+" + CommitHash
}
if v.Label != "" {
return fmt.Sprintf("%d.%d.%d-%s%s",
v.Major, v.Minor, v.Patch, v.Label, hashStr)
}
return fmt.Sprintf("%d.%d.%d%s",
v.Major, v.Minor, v.Patch, hashStr)
}