semver

package
v0.0.0-...-ea07d1b Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: EUPL-1.2 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisallowedLeadingZero = errors.New("disallowed leading zero")
	ErrBadVersionFormat      = errors.New("bad version format")
	ErrVersionOutOfRange     = errors.New("version is out of range")
)

Functions

func Compare

func Compare(v1, v2 Version) int

func JoinSegments

func JoinSegments(segments []Segment, sep string) string

Types

type Segment

type Segment struct {
	// contains filtered or unexported fields
}

func NewNumericSegment

func NewNumericSegment(numeric uint64) Segment

func NewSegment

func NewSegment(text string) Segment

func (*Segment) IsNumeric

func (s *Segment) IsNumeric() bool

func (*Segment) String

func (s *Segment) String() string

func (*Segment) Uint64

func (s *Segment) Uint64() uint64

type Version

type Version struct {
	Major, Minor, Patch uint32
	HasVPrefix          bool
	Prerelease          []Segment
	BuildMetadata       []Segment
}

func MustParse

func MustParse(s string) Version

MustParse is the same as Parse, but it will panic if there's an error. Useful when you're hardcoding the argument.

func New

func New(major, minor, patch uint32) Version

New makes it quick and easy to create a new Version.

func Parse

func Parse(s string) (Version, error)

Parse will parse a string and returns Version.

func (*Version) ClearBuildMetadata

func (v *Version) ClearBuildMetadata()

ClearBuildMetadata clears BuildMetadata

func (*Version) ClearPrerelease

func (v *Version) ClearPrerelease()

ClearPrerelease clears Prerelease

func (*Version) Clone

func (v *Version) Clone() Version

Clone returns an exact clone of Version.

func (*Version) Finalize

func (v *Version) Finalize()

Finalize will clear both Prerelease and BuildMetadata.

func (*Version) IncreaseMajor

func (v *Version) IncreaseMajor()

IncreaseMajor will increase Major, set Minor and Patch to zero and clear Prerelease and BuildMetadata.

func (*Version) IncreaseMinor

func (v *Version) IncreaseMinor()

IncreaseMinor will increase Minor, set Patch to zero and clear Prerelease and BuildMetadata.

func (*Version) IncreasePatch

func (v *Version) IncreasePatch()

IncreasePatch will increase Patch, and clear Prerelease and BuildMetadata.

func (*Version) IsZero

func (v *Version) IsZero() bool

IsZero returns true if Major, Minor, Patch, Prerelease and BuildMetadata is empty.

func (*Version) MarshalText

func (v *Version) MarshalText() ([]byte, error)

func (*Version) SetBuildMetadata

func (v *Version) SetBuildMetadata(segments ...string) error

SetBuildMetadata will set the build metadata and overwrite the previous build metadata. The function takes one or more arguments where each argument is a build identifier. To set it to `alpha.1`, pass "alpha" and "1" as two separate arguments.

func (*Version) SetPrerelease

func (v *Version) SetPrerelease(segments ...string) error

SetPrerelease will set the prerelease information and overwrite the previous prerelease information. The function takes one or more arguments where each argument is a Prerelease identifier. To set it to `alpha.1`, pass "alpha" and "1" as two separate arguments.

func (*Version) String

func (v *Version) String() string

String returns a string representation of Version.

func (*Version) UnmarshalText

func (v *Version) UnmarshalText(b []byte) error

Jump to

Keyboard shortcuts

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