version.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This file is subject to a 1-clause BSD license.
  2. // Its contents can be found in the enclosed LICENSE file.
  3. // Package app defines some utility code which may be shared between packages.
  4. package app
  5. import (
  6. "fmt"
  7. "runtime"
  8. )
  9. // Application name and version constants.
  10. const (
  11. Name = "autimaat"
  12. VersionMajor = 1
  13. VersionMinor = 15
  14. )
  15. // VersionRevision defines the application build number.
  16. // This needs to be a string, as it is defined externally
  17. // through a command line option:
  18. //
  19. // go install -ldflags "-X github.com/monkeybird/autimaat/app.VersionRevision=`date -u +%s`"
  20. //
  21. // Note that the entire import path must be specified for this to work.
  22. //
  23. var VersionRevision string
  24. func init() {
  25. // Make sure the revision has a sane value.
  26. if len(VersionRevision) == 0 {
  27. VersionRevision = "0"
  28. }
  29. }
  30. // Version returns the application version as a string.
  31. func Version() string {
  32. return fmt.Sprintf("%s %d.%d.%s (Go runtime %s)",
  33. Name, VersionMajor, VersionMinor, VersionRevision, runtime.Version())
  34. }