packer-cn/vendor/github.com/Azure/go-autorest/autorest/version.go

36 lines
624 B
Go
Raw Normal View History

2016-03-14 23:04:46 -04:00
package autorest
import (
2017-05-28 02:13:26 -04:00
"bytes"
2016-03-14 23:04:46 -04:00
"fmt"
2017-05-28 02:13:26 -04:00
"strings"
"sync"
2016-03-14 23:04:46 -04:00
)
const (
2017-05-28 02:13:26 -04:00
major = 8
minor = 0
patch = 0
tag = ""
2016-03-14 23:04:46 -04:00
)
2017-05-28 02:13:26 -04:00
var once sync.Once
var version string
2016-03-14 23:04:46 -04:00
// Version returns the semantic version (see http://semver.org).
func Version() string {
2017-05-28 02:13:26 -04:00
once.Do(func() {
semver := fmt.Sprintf("%d.%d.%d", major, minor, patch)
verBuilder := bytes.NewBufferString(semver)
if tag != "" && tag != "-" {
updated := strings.TrimPrefix(tag, "-")
_, err := verBuilder.WriteString("-" + updated)
if err == nil {
verBuilder = bytes.NewBufferString(semver)
}
}
version = verBuilder.String()
})
return version
2016-03-14 23:04:46 -04:00
}