ver2go

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: BSD-3-Clause Imports: 1 Imported by: 17

README

ver2go

License GitHub release Last Commit Go Go Report Card Go Reference

Version utilities for Go

Introduction

Provides basic version library for use in Go projects.

Table of Contents

Installation

Install via go get, as in:

go get "github.com/synesissoftware/ver2go"

and then import as:

import ver2go "github.com/synesissoftware/ver2go"

or, simply, as:

import "github.com/synesissoftware/ver2go"

Components

The current version of the library consists of the single API function CalcVersionString():

func CalcVersionString(verMajor, verMinor, verPatch, verAB uint16) string

The meaning of the four parameters are:

  • verMajor - the major version;
  • verMinor - the minor version;
  • verPatch - the patch version;
  • verAB - the alpha/beta version;

See the function documentation for details of the rules, but the following examples are illustrative:

ver2go.CalcVersionString(0, 0, 0, 0) // => "0.0.0"
ver2go.CalcVersionString(1, 2, 3, 0xFFFF) // => "1.2.3"
ver2go.CalcVersionString(0, 0, 1, 0x1234) // => "0.0.1.4660"
ver2go.CalcVersionString(0, 1, 2, 0x4321) // => "0.1.2-alpha801"
ver2go.CalcVersionString(0, 1, 0, 0x8765) // => "0.1.0-beta1893"
ver2go.CalcVersionString(1, 2, 3, 0xC007) // => "1.2.3-rc7"

Examples

Examples are provided in the examples directory, along with a markdown description for each. A detailed list TOC of them is provided in EXAMPLES.md.

Project Information

Where to get help

GitHub Page

Contribution guidelines

Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/ver2go.

Dependencies

None

Development/Testing Dependencies
Dependents
License

ver2go is released under the 3-clause BSD license. See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	VersionMajor uint16 = 0
	VersionMinor uint16 = 1
	VersionPatch uint16 = 2
	VersionAB    uint16 = 0xFFFF
	Version      uint64 = (uint64(VersionMajor) << 48) + (uint64(VersionMinor) << 32) + (uint64(VersionPatch) << 16) + (uint64(VersionAB) << 0)
)

Variables

This section is empty.

Functions

func CalcVersionString

func CalcVersionString(verMajor, verMinor, verPatch, verAB uint16) string

Calculates a version string, which is conventionally a dotted string of the form "<MAJOR>.<MINOR>.<PATCH>", where each of <MAJOR>, <MINOR>, <PATCH> is a number, e.g. "1.2.3". This is the form presented when either of the following two conditions is true:

1. All of `verMajor`, `verMinor`, `verPatch` have the value 0; or 2. `VersionAB` has the value 0xffff.

In all other cases, the version string takes the form of "<MAJOR>.<MINOR>.<PATCH>.<AB_DGNTR>", where <AB_DGNTR> - called the αβ-designator - has a variety of forms as described by the following rules (listed in order of precedence):

  1. If both `verMajor` and `verMinor` have the value 0, then the αβ-designator is a simple number, as in "0.0.13.5432";
  2. If `verAB` is >= 0xC000, then αβ-designator designates a "release candidate" where the RC number is verAB-0xC000, e.g. "0.1.2-rc1" (for a `verAB` of 0xC002);
  3. If `verAB` is >= 0x8000, then αβ-designator designates a "beta" where the RC number is verAB-0x800), e.g. "0.1.2-beta13" (for a `verAB` of 0x800D);
  4. If `verAB` is >= 0x4000, then αβ-designator designates an "alpha" where the RC number is verAB-0x800), e.g. "0.1.2-alpha7" (for a `verAB` of 0x8007);
  5. If `verAB` is > 0, then αβ-designator designates something sub-alpha, perhaps an experimental release, and is given a plain number form, e.g. "0.1.2.4660" (for a `verAB` of 0x1234).

func VersionString

func VersionString() string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL