buildinfo.go 902 B

1234567891011121314151617181920212223
  1. // Package buildinfo exposes the build-time version metadata injected via
  2. // -ldflags "-X vocat/internal/buildinfo.Version=... -X vocat/internal/buildinfo.BuildTime=...".
  3. // It is imported by the server (to report version through /api/system/info),
  4. // the CLI subcommands (vocat version / update), and the self-updater (to
  5. // compare the running build against a GitHub release).
  6. package buildinfo
  7. // Version is the semantic version of this build. It defaults to the dev
  8. // sentinel when no -ldflags override is supplied.
  9. var Version = "0.1.0-dev"
  10. // BuildTime is the UTC timestamp the binary was built at (RFC3339), or empty
  11. // for a local dev build.
  12. var BuildTime = ""
  13. // Build returns a human-readable version string. When BuildTime is populated
  14. // it appends the timestamp in parentheses.
  15. func Build() string {
  16. if BuildTime == "" {
  17. return Version
  18. }
  19. return Version + " (" + BuildTime + ")"
  20. }