Categorygithub.com/neaas/go-version
modulepackage
0.1.1
Repository: https://github.com/neaas/go-version.git
Documentation: pkg.go.dev

# README

GoVersion    GitHub release (latest SemVer)  GitHub Workflow Status

Go Reference

A (very) simple go package for handling semver compliant application versions.


Features

  • Immutable application version, set via linker flags.
  • Values from runtime/debug available.
  • Check for updates using public GitHub release/tag information.

Usage

Somewhere in your application, be sure that this package is imported:

import (
  _ "github.com/neaas/go-version"
)

Configuration

Set each configuration value using the linker flags as described below:

go build -ldflags "-X github.com/neaas/go-version.VARIABLE=VALUE" .
VariableDescriptionDefault Value
versionThe semver compliant version of the application being built.v0.0.0+unversioned
repositoryOwnerThe owner of the GitHub repository for the application.neaas
repositoryNameThe name of the application's GitHub repository.go-version
versionTypeThe method in which versions are defined for the repository
(release, tag, none)
tag

# Functions

Build returns the build metadata value of the version if any.
DepVersion returns the version of a given dependency used.
Equal returns true if the application version is equal to version v.
GoVersion returns the golang version that was used to build the application.
GreaterThan returns true if the application version is greater than v.
GreaterThanEqual returns true if the application version is greater than or equal to version v.
IsUnversioned returns true if the version is the default unversioned string.
IsValid returns true if the version is in a state that is compatible with this package.
LatestVersion determines the latest version that is valid semver and not prerelease from a given set of version strings.
LessThan returns true if the application version is less than version v.
LessThanEqual returns true if the application version is less than or equal to version v.
Prerelease returns the prerelease value of the version if any.
RepoVersions fetches all of the releases/tags from the GitHub repository with the owner and name provided and reports back all the semver compliant tag names coupled with them.
Update checks if the current application's version is lower than that of the version provided (only if the provided version is semver compliant).
VCSCommit returns the version control system commit associated with the application's binary.
Version returns the canonically formatted semver compliant version string (with the 'v' prefix) or the default unversioned string.
Versions fetches all of the releases/tags from the application's associated GitHub repository and reports back all the semver compliant tag names coupled with them.