version: Don't export funcs/vars unnecessarily.

This commit is contained in:
jholdstock 2023-09-11 15:16:24 +01:00 committed by Jamie Holdstock
parent 3d4fb6ab99
commit b5ffecd280
2 changed files with 13 additions and 9 deletions

View File

@ -96,7 +96,7 @@ func (v *vspd) run() int {
runtime.GOOS, runtime.GOARCH)
if v.cfg.netParams == &mainNetParams &&
version.PreRelease != "" {
version.IsPreRelease() {
v.log.Warnf("")
v.log.Warnf("\tWARNING: This is a pre-release version of vspd which should not be used on mainnet.")
v.log.Warnf("")

View File

@ -17,28 +17,32 @@ const semverAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst
// Constants defining the application version number.
const (
Major = 1
Minor = 3
Patch = 0
major = 1
minor = 3
patch = 0
)
// PreRelease contains the prerelease name of the application. It is a variable
// preRelease contains the prerelease name of the application. It is a variable
// so it can be modified at link time (e.g.
// `-ldflags "-X decred.org/vspd/version.PreRelease=rc1"`).
// `-ldflags "-X decred.org/vspd/version.preRelease=rc1"`).
// It must only contain characters from the semantic version alphabet.
var PreRelease = "pre"
var preRelease = "pre"
func IsPreRelease() bool {
return preRelease != ""
}
// String returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (https://semver.org/).
func String() string {
// Start with the major, minor, and path versions.
version := fmt.Sprintf("%d.%d.%d", Major, Minor, Patch)
version := fmt.Sprintf("%d.%d.%d", major, minor, patch)
// 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.
preRelease := normalizeVerString(PreRelease)
preRelease := normalizeVerString(preRelease)
if preRelease != "" {
version = version + "-" + preRelease
}