github.com/puellanivis/breton@v0.2.16/lib/os/process/version.go (about)

     1  package process
     2  
     3  var versionString string
     4  
     5  // Version returns the full version information populated during process.Init().
     6  //
     7  // This function is intended to implement a `--version` flag, and thus returns `"cmdname version[-buildstamp]"`.
     8  // It does _not_ return just the `"version[-buildstamp]"` information, for that use `AppVersion()`.
     9  func Version() string {
    10  	return versionString
    11  }
    12  
    13  var (
    14  	appName    string
    15  	appVersion string
    16  )
    17  
    18  // AppName returns the command name populated during process.Init().
    19  func AppName() string {
    20  	return appName
    21  }
    22  
    23  // AppVersion returns only the version and buildstamp populated during process.Init().
    24  func AppVersion() string {
    25  	return appVersion
    26  }
    27  
    28  func buildVersion(cmdname, version, buildstamp string) {
    29  	appName, appVersion = cmdname, version
    30  	if buildstamp != "" {
    31  		appVersion += "-" + buildstamp
    32  	}
    33  
    34  	versionString = appName + " " + appVersion
    35  }