github.com/docker/cnab-to-oci@v0.3.0-beta4/internal/version.go (about) 1 package internal 2 3 import ( 4 "fmt" 5 "runtime" 6 "strings" 7 "time" 8 ) 9 10 var ( 11 // Version is the git tag that this was built from. 12 Version = "unknown" 13 // GitCommit is the commit that this was built from. 14 GitCommit = "unknown" 15 // BuildTime is the time at which the binary was built. 16 BuildTime = "unknown" 17 ) 18 19 // FullVersion returns a string of version information. 20 func FullVersion() string { 21 res := []string{ 22 fmt.Sprintf("Version: %s", Version), 23 fmt.Sprintf("Git commit: %s", GitCommit), 24 fmt.Sprintf("Built: %s", reformatDate(BuildTime)), 25 fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH), 26 } 27 return strings.Join(res, "\n") 28 } 29 30 // FIXME(chris-crone): use function in docker/cli/cli/command/system/version.go. 31 func reformatDate(buildTime string) string { 32 t, errTime := time.Parse(time.RFC3339Nano, buildTime) 33 if errTime == nil { 34 return t.Format(time.ANSIC) 35 } 36 return buildTime 37 }