version

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownVersionFormat = errors.New("unknown version format")
	ErrBadVersionTime       = errors.New("could not parse the version timestamp")
	ErrUnknownOutputFormat  = errors.New("unknown output format")
)

Functions

func MergeVersions

func MergeVersions(dst, src *Version)

MergeVersions merges the components of src Version into dst Version, only if the respective components in dst are empty or zero.

Types

type Info

type Info struct {
	Version string    // version string, in Go format
	Time    time.Time `json:",omitempty"` // code timestamp (unreliable)
	Build   string    `json:",omitempty"` // Build (semver) / Release (RPM)
	Epoch   int       `json:",omitempty"` // versioning Epoch (RPM)
}

Info represents module proxy information.

func NewInfo

func NewInfo(version string, Time time.Time, build string, epoch int) *Info

NewInfo creates a new Info instance with the provided version, time, build, and epoch.

func (*Info) Ver

func (ver *Info) Ver() (*Version, error)

Ver returns the Version representation of the Info. It creates a new Version instance from the Info components and Go version string.

type Version

type Version struct {
	Epoch   int
	Version string
	Pre     string
	Commit  string
	Time    time.Time
	Build   string
}

Version represents a version with epoch, version, pre-release, commit, timestamp, and build.

func FromGo

func FromGo(raw string) (*Version, error)

FromGo creates a Version instance from a Go version string. It parses the version string and extracts components using regular expressions.

func New

func New(version, pre, commit, timestamp, build string, epoch int) (*Version, error)

New creates a new Version instance from the provided components. It validates and processes each component and returns a Version instance or an error if any component is invalid.

func (*Version) Format

func (ver *Version) Format(format string) (string, error)

Format returns the version string in the specified format (e.g., "rpm" or "go"). It calls the appropriate method to generate the version string or returns an error if the format is unknown.

func (*Version) Go

func (ver *Version) Go() string

Go returns the Go format version string of the Version instance. It constructs the string from the version components, following Go versioning conventions.

func (*Version) Info

func (ver *Version) Info() *Info

Info returns the Info representation of the Version. It creates a new Info instance using the version components.

func (*Version) RPM

func (ver *Version) RPM() string

RPM returns the RPM format version string of the Version instance. It constructs the string from the version components, following RPM versioning conventions.

Jump to

Keyboard shortcuts

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