github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/version/version.go (about)

     1  package version
     2  
     3  import "github.com/blang/semver"
     4  
     5  const DefaultVersion = "0.0.0-unknown-version"
     6  
     7  var (
     8  	binaryVersion   string
     9  	binarySHA       string
    10  	binaryBuildDate string
    11  )
    12  
    13  func VersionString() string {
    14  	versionString, err := semver.Make(binaryVersion)
    15  	if err != nil {
    16  		versionString = semver.MustParse(DefaultVersion)
    17  	}
    18  
    19  	metaData := []string{}
    20  	if binarySHA != "" {
    21  		metaData = append(metaData, binarySHA)
    22  	}
    23  
    24  	if binaryBuildDate != "" {
    25  		metaData = append(metaData, binaryBuildDate)
    26  	}
    27  
    28  	versionString.Build = metaData
    29  
    30  	return versionString.String()
    31  }