123456789101112131415161718192021222324252627282930313233 |
- package version
- import (
- "fmt"
- "runtime/debug"
- )
- var version = func() string {
- ver := "2.10.1"
- if info, ok := debug.ReadBuildInfo(); ok {
- var revision string
- var modified string
- for _, setting := range info.Settings {
- switch setting.Key {
- case "vcs.revision":
- revision = setting.Value[:8]
- case "vcs.modified":
- if setting.Value == "true" {
- modified = "*"
- }
- }
- }
- if revision != "" {
- return fmt.Sprintf("%v (%v%v)", ver, revision, modified)
- }
- }
- return ver
- }()
- func GetVersion() string {
- return version
- }
|