version

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

version module

The version package provides some utilities to get and display the version of a system, including branch, revision, and the dirty flag status.

Constants

The following are placeholders that are replaced during the build of the system.

  • Branch: Represents the branch the system is running of.
  • Revision: Represents the code revision.
  • Dirty: Shows if the binary was built from a repo with uncommitted changes.

Version Interface

The Version interface defines two methods for retrieving version information

  • Short() string: Returns a short representation of the version.
  • String() string: Returns a detailed representation of the version.

Functions

Current()

Returns the current version as a Version object

ShowAndExit(short bool)

Prints the version information and exits the program

  • If short is true, prints the short version.
  • Otherwise, prints the detailed version.
Parse(v string)

Parses a version string using regular expressions and extracts the version and revision. Returns an error if the string is invalid

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Branch of the code
	Branch = "{branch}"
	// Revision of the code
	Revision = "{revision}"
	// Dirty flag shows if the binary is built from a
	// repo with uncommitted changes
	Dirty = "{dirty}"
)

Functions

func Parse

func Parse(v string) (version string, revision string, err error)

Parse version string

func ShowAndExit

func ShowAndExit(short bool)

ShowAndExit prints the version and exits

Types

type Version

type Version interface {
	Short() string
	String() string
}

Version interface

func Current

func Current() Version

Current get current version

Jump to

Keyboard shortcuts

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