version.go raw

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