github.com/sandwich-go/boost@v1.3.29/version/version.go (about) 1 package version 2 3 import ( 4 "fmt" 5 ) 6 7 // Build information. Populated at build-time. 8 var ( 9 Version = "unknown" 10 Revision = "unknown" 11 Branch = "unknown" 12 BuildUser = "unknown" 13 BuildDate = "unknown" 14 UserData = "unknown" 15 ) 16 17 // Info provides the iterable version information. 18 var Info = map[string]string{ 19 "version": Version, 20 "revision": Revision, 21 "branch": Branch, 22 "build_user": BuildUser, 23 "build_date": BuildDate, 24 "user_data": UserData, 25 } 26 27 // Valid version info is valid 28 func Valid() bool { return Version != "unknown" } 29 30 // String format version info 31 func String() string { 32 if UserData == "unknown" || UserData == "" { 33 return fmt.Sprintf("%s_%s_%s_%s_%s", Version, Revision, Branch, BuildUser, BuildDate) 34 } 35 return fmt.Sprintf("%s_%s_%s_%s_%s_%s", Version, Revision, Branch, BuildUser, BuildDate, UserData) 36 }