1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

Add new TASK_VERSION special variable

Closes #1014
Closes #990
This commit is contained in:
João Pedro
2023-02-19 22:28:17 -03:00
committed by Andrey Nering
parent 12a1cd6f62
commit ec2110e58f
10 changed files with 45 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
package version
import (
"fmt"
"runtime/debug"
)
var version = ""
func GetVersion() string {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok || info.Main.Version == "" {
return "unknown"
}
ver := info.Main.Version
if info.Main.Sum != "" {
ver += fmt.Sprintf(" (%s)", info.Main.Sum)
}
return ver
}