Improve binapi generator
[govpp.git] / internal / version / version.go
similarity index 83%
rename from version/version.go
rename to internal/version/version.go
index 8bde72c..7148019 100644 (file)
@@ -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,6 +22,22 @@ import (
        "time"
 )
 
+const (
+       Major      = 0
+       Minor      = 4
+       Patch      = 0
+       PreRelease = "dev"
+)
+
+// 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.