semverpair

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 4 Imported by: 0

README

This library speficies a simple encoding and decoding scheme to combine two semver versions into one.

My intended use for this is as a versioning scheme for Hugo Modules that are wrappers of upstream libraries. The wrapper and library have diverging release cycles, and we want to maintain the upstream version info, so we cannot just use the upstream version as is.

Features:

  • The upstream library controls the major version.
  • It should be easy to determine the upstream version just by looking at it.
  • It should always be possible to programmatially decode back to the originals.
  • A minor or patch increment from either of the two versions should result in a version that is greater than the previous version.

The minor and patch version:

  • Starts out with one digit (width) telling how many digits each version holds.
  • Then each version is printed padded with leading zeros.

Some examples a width of 2 digits per version:

  • v3.0.0 + v3.0.0 = v3.20000.20000
  • v3.1.0 + v3.0.0" = v3.20100.20000
  • v3.6.5 + v3.99.99 = v3.20699.20599

If either of the versions reaches 100, the prefix can be incremented:

  • v3.6.5 + v3.99.100 = v3.20699.3005100

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	First  Version
	Second Version
}

Pairs represents a pair of semver version sharing the same major version.

func Decode

func Decode(v Version) Pair

Decode decodes the given semver triplet into the original version pair.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version represents a semver version.

func Encode

func Encode(pair Pair) Version

Encode encodes two semver versions that share the same major version into one. The encoded version can be decoded back to the originals using Decode.

func (Version) String

func (v Version) String() string

String formats the version triplet as a semver string, e.g. v3.5.2.

Jump to

Keyboard shortcuts

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