From 280caa4591da5f0deb721f14db4c5d2f6be68698 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 2 Feb 2023 15:45:53 +0000 Subject: [PATCH 1/2] version: simplify parsing logic --- version.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/version.go b/version.go index 198cd3b5e..72848d5d3 100644 --- a/version.go +++ b/version.go @@ -16,15 +16,10 @@ var ( //go:embed version/VERSION rawVersion string - fullVersion = parseRawVersion(rawVersion) + version = goversion.Must(goversion.NewVersion(rawVersion)) ) // VersionString returns the complete version string, including prerelease func VersionString() string { - return fullVersion.String() -} - -func parseRawVersion(rawVersion string) goversion.Version { - v := goversion.Must(goversion.NewVersion(rawVersion)) - return *v + return version.String() } From aacd5a0d0167ce375393ea0f48db344f21db952f Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 2 Feb 2023 15:46:17 +0000 Subject: [PATCH 2/2] version: trim spaces from raw VERSION This is useful e.g. when VERSION file is edited via GitHub UI, which automatically adds a trailing newline. --- version.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.go b/version.go index 72848d5d3..63577c2a2 100644 --- a/version.go +++ b/version.go @@ -2,6 +2,7 @@ package main import ( _ "embed" + "strings" goversion "github.com/hashicorp/go-version" ) @@ -16,7 +17,7 @@ var ( //go:embed version/VERSION rawVersion string - version = goversion.Must(goversion.NewVersion(rawVersion)) + version = goversion.Must(goversion.NewVersion(strings.TrimSpace(rawVersion))) ) // VersionString returns the complete version string, including prerelease