This commit is contained in:
Shen Junzheng
2025-03-12 01:19:35 +08:00
parent 160040f3e1
commit 78cce92ce3
70 changed files with 10134 additions and 1 deletions

32
pkg/version/version.go Normal file
View File

@@ -0,0 +1,32 @@
package version
import (
"fmt"
"runtime"
"runtime/debug"
"strings"
)
var (
Version = "(dev)"
buildInfo = debug.BuildInfo{}
)
func init() {
if bi, ok := debug.ReadBuildInfo(); ok {
buildInfo = *bi
if len(bi.Main.Version) > 0 {
Version = bi.Main.Version
}
}
}
func GetMore(mod bool) string {
if mod {
mod := buildInfo.String()
if len(mod) > 0 {
return fmt.Sprintf("\t%s\n", strings.ReplaceAll(mod[:len(mod)-1], "\n", "\n\t"))
}
}
return fmt.Sprintf("version %s %s %s/%s\n", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
}