From b5ffecd280d9e1b607c4dd1cdac336bbdb39af75 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Mon, 11 Sep 2023 15:16:24 +0100 Subject: [PATCH] version: Don't export funcs/vars unnecessarily. --- cmd/vspd/vspd.go | 2 +- internal/version/version.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/vspd/vspd.go b/cmd/vspd/vspd.go index 82e4428..5080488 100644 --- a/cmd/vspd/vspd.go +++ b/cmd/vspd/vspd.go @@ -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("") diff --git a/internal/version/version.go b/internal/version/version.go index f9b08ec..2bbc314 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -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 }