semver

package
v0.0.0-...-9752724 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2014 License: MIT, MPL-2.0 Imports: 5 Imported by: 0

README

Semantic Versioning.

Semntatic Versioning with support for product part and some extra limitations.

Constraints are based on hashicorp/go-version.

TODO:
  • Finish this README.
  • Add more tests.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//Exported vars.
	ErrorMalformedVersionPre = Error{"Malformed Version Pre part: %s", ""}
	PrereleaseTags           = []string{"pre", "alpha", "beta", "rc"}
)
View Source
var (
	ErrorMalformedVersion = Error{"Malformed Version: %s", ""}
)
View Source
var (
	ErrorVersionNotFound = Error{"Version %s not found.", ""}
)

Functions

func Parts

func Parts(raw string) ([]string, error)

Types

type Collection

type Collection []*Version

Collection is a type that implements the sort.Interface interface so that versions can be sorted.

func NewCollection

func NewCollection(raws []string) (Collection, error)

func (Collection) Latest

func (vc Collection) Latest(constraints string) (*Version, error)

func (Collection) Len

func (vc Collection) Len() int

func (Collection) Less

func (vc Collection) Less(i, j int) bool

TODO: Check why sort.Reverse isn't working.

func (Collection) Swap

func (vc Collection) Swap(i, j int)

type Constraint

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

Constraint represents a single constraint for a version, such as ">= 1.0".

func (*Constraint) Check

func (c *Constraint) Check(v *Version) bool

Check tests if a constraint is validated by the given version.

func (*Constraint) String

func (c *Constraint) String() string

type Constraints

type Constraints []*Constraint

Constraints is a slice of constraints. We make a custom type so that we can add methods to it.

func NewConstraint

func NewConstraint(v string) (Constraints, error)

NewConstraint will parse one or more constraints from the given constraint string. The string must be a comma-separated list of constraints.

func (Constraints) Check

func (cs Constraints) Check(v *Version) bool

Check tests if a version satisfies all the constraints.

func (Constraints) String

func (cs Constraints) String() string

Returns the string format of the constraints

type Error

type Error struct {
	Err      string
	Detailed string
}

func (Error) Error

func (e Error) Error() string

func (*Error) Fault

func (e *Error) Fault(details ...interface{}) *Error

type Pre

type Pre struct {
	Ident string
	Patch int
}

func NewPre

func NewPre(raw string) (*Pre, error)

func (*Pre) Compare

func (v *Pre) Compare(o *Pre) int

func (*Pre) String

func (p *Pre) String() string

type Version

type Version struct {
	Raw string

	Product string

	Major uint16
	Minor uint16
	Patch uint16
	Pre   *Pre
	Meta  string
}

func NewVersion

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

func (*Version) Compare

func (v *Version) Compare(o *Version) int

func (*Version) Equal

func (v *Version) Equal(o *Version) bool

func (*Version) GreaterThan

func (v *Version) GreaterThan(o *Version) bool

func (*Version) GreaterThanOrEqual

func (v *Version) GreaterThanOrEqual(o *Version) bool

func (*Version) LessThan

func (v *Version) LessThan(o *Version) bool

func (*Version) LessThanOrEqual

func (v *Version) LessThanOrEqual(o *Version) bool

func (*Version) NotEqual

func (v *Version) NotEqual(o *Version) bool

func (*Version) String

func (v *Version) String() string

func (*Version) StringWithMeta

func (v *Version) StringWithMeta() string

Jump to

Keyboard shortcuts

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