Skip to content

Commit

Permalink
version: Don't export funcs/vars unnecessarily.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock committed Sep 13, 2023
1 parent 3d4fb6a commit b5ffecd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/vspd/vspd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down
20 changes: 12 additions & 8 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b5ffecd

Please sign in to comment.