1 // Copyright (c) 2019 Cisco and/or its affiliates.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at:
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // Package version keeps track of versioning info for GoVPP.
32 // String formats the version string using semver format.
33 func String() string {
34 v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch)
41 // Following variables should normally be updated via `-ldflags "-X ..."`.
42 // However, the version string is hard-coded to ensure it is always included
43 // even with bare go build/install.
46 version = "v0.6.0-dev"
57 buildstampInt64, _ := strconv.ParseInt(buildStamp, 10, 64)
58 if buildstampInt64 == 0 {
59 buildstampInt64 = time.Now().Unix()
61 buildDate = time.Unix(buildstampInt64, 0)
64 func Version() string {
69 return fmt.Sprintf(`%s %s`, name, version)
72 func Verbose() string {
73 return fmt.Sprintf(`%s
79 Go runtime: %s (%s/%s)`,
81 version, branch, commit,
82 buildUser, buildHost, buildDate.Format(time.UnixDate),
83 runtime.Version(), runtime.GOOS, runtime.GOARCH,