psu/common/version.go
Juan Carlos Mejías Rodríguez a6a4a70996 Use + as a build metadata separator in version
Follows SemVer
2019-08-09 01:42:13 -04:00

37 lines
702 B
Go

package common
import (
"fmt"
"runtime"
"strings"
)
var (
// This is the current version of the client. It is set by goreleaser.
version string
// The program name
programName = "Portainer Stack Utils"
// commitHash contains the current Git revision. Use Go Releaser to make sure this gets set.
commitHash string
// buildDate contains the date of the current build.
buildDate string
)
func BuildVersionString() string {
if commitHash != "" {
version += "+" + strings.ToUpper(commitHash)
}
osArch := runtime.GOOS + "/" + runtime.GOARCH
date := buildDate
if date == "" {
date = "unknown"
}
return fmt.Sprintf("%s %s %s BuildDate: %s", programName, version, osArch, date)
}