Skip to content

Commit

Permalink
version: trim spaces from raw VERSION (#1165)
Browse files Browse the repository at this point in the history
* version: simplify parsing logic

* 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.
  • Loading branch information
radeksimko authored Feb 2, 2023
1 parent ec5055c commit a887e99
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
_ "embed"
"strings"

goversion "github.com/hashicorp/go-version"
)
Expand All @@ -16,15 +17,10 @@ var (
//go:embed version/VERSION
rawVersion string

fullVersion = parseRawVersion(rawVersion)
version = goversion.Must(goversion.NewVersion(strings.TrimSpace(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()
}

0 comments on commit a887e99

Please sign in to comment.