X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=version%2Fversion.go;h=21d5af9dd85b4988367f425ef31c2401036fc988;hb=66b2e881b96d9eff429d8136129f194a1d17da87;hp=8f3e82bbd877650a2a62b49d5538e114cd5b3a05;hpb=73733b0a8ab8612233c98f9828f5f563c69fc2b7;p=govpp.git diff --git a/version/version.go b/version/version.go index 8f3e82b..21d5af9 100644 --- a/version/version.go +++ b/version/version.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package version keeps track of versioning info for GoVPP. package version import ( @@ -21,14 +22,33 @@ import ( "time" ) +const ( + Major = 0 + Minor = 5 + Patch = 0 + PreRelease = "" +) + +// String formats the version string using semver format. +func String() string { + v := fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch) + if PreRelease != "" { + v += "-" + PreRelease + } + return v +} + +// Following variables should normally be updated via `-ldflags "-X ..."`. +// However, the version string is hard-coded to ensure it is always included +// even with bare go build/install. var ( - name = "govpp" - version = "v0.2.0" - commitHash = "unknown" - buildBranch = "HEAD" - buildStamp = "" - buildUser = "" - buildHost = "" + name = "govpp" + version = "v0.5.0" + commit = "unknown" + branch = "HEAD" + buildStamp = "" + buildUser = "" + buildHost = "" buildDate time.Time ) @@ -41,6 +61,10 @@ func init() { buildDate = time.Unix(buildstampInt64, 0) } +func Version() string { + return version +} + func Info() string { return fmt.Sprintf(`%s %s`, name, version) } @@ -54,7 +78,7 @@ func Verbose() string { Build date: %s Go runtime: %s (%s/%s)`, name, - version, buildBranch, commitHash, + version, branch, commit, buildUser, buildHost, buildDate.Format(time.UnixDate), runtime.Version(), runtime.GOOS, runtime.GOARCH, )