version.go 956 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package version
  2. import (
  3. "fmt"
  4. "os"
  5. "path/filepath"
  6. "runtime"
  7. )
  8. const Version = "2022.1.1"
  9. const MachineVersion = "v0.3.1"
  10. // version returns a version descriptor and reports whether the
  11. // version is a known release.
  12. func version(human, machine string) (human_, machine_ string, known bool) {
  13. if human != "devel" {
  14. return human, machine, true
  15. }
  16. v, ok := buildInfoVersion()
  17. if ok {
  18. return v, "", false
  19. }
  20. return "devel", "", false
  21. }
  22. func Print(human, machine string) {
  23. human, machine, release := version(human, machine)
  24. if release {
  25. fmt.Printf("%s %s (%s)\n", filepath.Base(os.Args[0]), human, machine)
  26. } else if human == "devel" {
  27. fmt.Printf("%s (no version)\n", filepath.Base(os.Args[0]))
  28. } else {
  29. fmt.Printf("%s (devel, %s)\n", filepath.Base(os.Args[0]), human)
  30. }
  31. }
  32. func Verbose(human, machine string) {
  33. Print(human, machine)
  34. fmt.Println()
  35. fmt.Println("Compiled with Go version:", runtime.Version())
  36. printBuildInfo()
  37. }