mirror of
https://github.com/go-task/task.git
synced 2025-01-12 04:34:11 +02:00
ec2110e58f
Closes #1014 Closes #990
26 lines
348 B
Go
26 lines
348 B
Go
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
|
|
}
|