1
0
mirror of https://github.com/go-task/task.git synced 2025-04-04 22:24:25 +02:00
task/internal/version/version.go
Valentin Maerten 1e25ceab29
fix: version check (#1663)
* fix: version check

* refactor following review
2024-05-20 21:48:05 +01:00

30 lines
393 B
Go

package version
import (
"fmt"
"runtime/debug"
)
var (
version = ""
sum = ""
)
func init() {
info, ok := debug.ReadBuildInfo()
if !ok || info.Main.Version == "" {
version = "unknown"
} else {
version = info.Main.Version
sum = info.Main.Sum
}
}
func GetVersion() string {
return version
}
func GetVersionWithSum() string {
return fmt.Sprintf("%s (%s)", version, sum)
}