forked from lightninglabs/pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
48 lines (38 loc) · 1.6 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
45
46
47
48
package pool
// Copyright (c) 2013-2017 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Heavily inspired by https://github.com/btcsuite/btcd/blob/master/version.go
// Copyright (C) 2015-2019 The Lightning Network Developers
import (
"fmt"
)
// Commit stores the current commit hash of this build, this should be set
// using the -ldflags during compilation.
var Commit string
// semanticAlphabet
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
// These constants define the application version and follow the semantic
// versioning 2.0.0 spec (http://semver.org/).
const (
appMajor uint = 0
appMinor uint = 4
appPatch uint = 1
// appPreRelease MUST only contain characters from semanticAlphabet per
// the semantic versioning spec.
appPreRelease = "alpha"
appPrereleaseVersion = 9
)
// Version returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (http://semver.org/).
func Version() string {
// Start with the major, minor, and patch versions.
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch)
// Append pre-release version if there is one. The hyphen called for
// by the semantic versioning spec is automatically appended and should
// not be contained in the pre-release string. The pre-release version
// is not appended if it contains invalid characters.
version = fmt.Sprintf("%s-%s.%d", version, appPreRelease, appPrereleaseVersion)
// Append commit hash of current build to version.
version = fmt.Sprintf("%s commit=%s", version, Commit)
return version
}