From ef9f28a693bac7c673918d0528eed08123905797 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 9 Jun 2022 15:26:28 +0100 Subject: [PATCH] main: allow version metadata to be set --- version.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/version.go b/version.go index 347c41738..c96de4461 100644 --- a/version.go +++ b/version.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - goversion "github.com/hashicorp/go-version" ) @@ -12,7 +10,10 @@ var version = "0.0.0" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. -var prerelease = "dev" +var versionPrerelease = "dev" + +// Version (build) metadata, such as homebrew +var versionMetadata = "" func init() { // Verify that the version is proper semantic version, which should always be the case. @@ -24,8 +25,14 @@ func init() { // VersionString returns the complete version string, including prerelease func VersionString() string { - if prerelease != "" { - return fmt.Sprintf("%s-%s", version, prerelease) + v := version + if versionPrerelease != "" { + v += "-" + versionPrerelease } - return version + + if versionMetadata != "" { + v += "+" + versionMetadata + } + + return v }