Add: version
parent
d6314954cc
commit
d426f82165
|
@ -0,0 +1,32 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
// Version 版本号
|
||||
Version = ""
|
||||
// GitCommit CommitID
|
||||
GitCommit = ""
|
||||
// BuildTime 二进制构建事件
|
||||
BuildTime = ""
|
||||
// GoVersion Go 版本号
|
||||
GoVersion = runtime.Version()
|
||||
)
|
||||
|
||||
// GetVersion 获取版本信息
|
||||
func GetVersion() string {
|
||||
return fmt.Sprintf(
|
||||
"Version : %s\nGitCommit: %s\nBuildTime: %s\nGoVersion: %s",
|
||||
Version, GitCommit, BuildTime, GoVersion,
|
||||
)
|
||||
}
|
||||
|
||||
// ShowVersionAndExit 打印版本信息并退出
|
||||
func ShowVersionAndExit() {
|
||||
fmt.Printf("%s", GetVersion()) // nolint:forbidigo
|
||||
os.Exit(0)
|
||||
}
|
Loading…
Reference in New Issue