bump_version

package
v0.0.0-...-3920266 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bump_version makes it easy to parse and update version numbers in Go source files.

Index

Constants

View Source
const (
	Major = VersionType("major")
	Minor = VersionType("minor")
	Patch = VersionType("patch")
)
View Source
const VERSION = "2.5"

Variables

This section is empty.

Functions

func Less

func Less(i, j Version) bool

Less reports whether i is a lower version number than j.

func SetInFile

func SetInFile(newVersion Version, filename string) error

SetInFile sets the version in filename to newVersion.

func ValidVersionType

func ValidVersionType(vtype VersionType) bool

Types

type Version

type Version struct {
	Major int64
	// May be "-1" to signify that this version field is unused.
	Minor int64
	Patch int64
}

func Bump

func Bump(version Version, vtype VersionType) Version

Bump increments the version number by the given vtype (major/minor/patch). Bump panics if vtype is not a known VersionType.

func BumpInFile

func BumpInFile(vtype VersionType, filename string) (Version, error)

BumpInFile finds a constant named VERSION, version, or Version in the file with the given filename, increments the version per the given VersionType, and writes the file back to disk. Returns the incremented Version object.

func GetInFile

func GetInFile(filename string) (Version, error)

GetInFile returns the version found in the file.

func Parse

func Parse(version string) (Version, error)

Parse parses a version string of the forms "2", "2.3", or "0.10.11". Any information after the third number ("2.0.0-beta") is discarded. Very little effort is taken to validate the input.

If a field is omitted from the string version (e.g. "0.2"), it's stored in the Version struct as the integer -1.

func (Version) String

func (v Version) String() string

type VersionType

type VersionType string

Jump to

Keyboard shortcuts

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