github.com/Hashicorp/packer@v1.3.2/version/version.go (about)

     1  package version
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  )
     7  
     8  // The git commit that was compiled. This will be filled in by the compiler.
     9  var GitCommit string
    10  
    11  // The main version number that is being run at the moment.
    12  const Version = "1.3.2"
    13  
    14  // A pre-release marker for the version. If this is "" (empty string)
    15  // then it means that it is a final release. Otherwise, this is a pre-release
    16  // such as "dev" (in development), "beta", "rc1", etc.
    17  const VersionPrerelease = ""
    18  
    19  func FormattedVersion() string {
    20  	var versionString bytes.Buffer
    21  	fmt.Fprintf(&versionString, "%s", Version)
    22  	if VersionPrerelease != "" {
    23  		fmt.Fprintf(&versionString, "-%s", VersionPrerelease)
    24  
    25  		if GitCommit != "" {
    26  			fmt.Fprintf(&versionString, " (%s)", GitCommit)
    27  		}
    28  	}
    29  
    30  	return versionString.String()
    31  }