package version import ( "fmt" "runtime" ) // These variables are set during build time via ldflags var ( Version = "dev" GitCommit = "unknown" BuildDate = "unknown" GoVersion = runtime.Version() Platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) ) // Info holds version information type Info struct { Version string `json:"version"` GitCommit string `json:"git_commit"` BuildDate string `json:"build_date"` GoVersion string `json:"go_version"` Platform string `json:"platform"` } // Get returns version information func Get() Info { return Info{ Version: Version, GitCommit: GitCommit, BuildDate: BuildDate, GoVersion: GoVersion, Platform: Platform, } } // String returns a formatted version string func String() string { info := Get() return fmt.Sprintf("teleport version %s (commit: %s, built: %s, go: %s, platform: %s)", info.Version, info.GitCommit, info.BuildDate, info.GoVersion, info.Platform) } // Short returns a short version string func Short() string { return fmt.Sprintf("teleport %s", Version) }