Documentation ¶
Overview ¶
Package version implements version parsing.
Index ¶
- Constants
- Variables
- func ParseMajorMinor(vers string) (int, int, error)
- type Binary
- func (b Binary) GetBSON() (interface{}, error)
- func (b Binary) MarshalJSON() ([]byte, error)
- func (b Binary) MarshalYAML() (interface{}, error)
- func (b *Binary) SetBSON(raw bson.Raw) error
- func (b Binary) String() string
- func (b *Binary) UnmarshalJSON(data []byte) error
- func (b *Binary) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Number
- func (n Number) Compare(other Number) int
- func (n Number) GetBSON() (interface{}, error)
- func (n Number) MarshalJSON() ([]byte, error)
- func (n Number) MarshalYAML() (interface{}, error)
- func (n *Number) SetBSON(raw bson.Raw) error
- func (n Number) String() string
- func (n Number) ToPatch() Number
- func (n *Number) UnmarshalJSON(data []byte) error
- func (n *Number) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
const ( // NumberRegex for matching version strings in the forms: // - 1.2 // - 1.2.3 // - 1.2.3.4 // - 1.2-alpha3 // - 1.2-alpha3.4 NumberRegex = `` /* 140-byte string literal not displayed */ // BinaryRegex for matching binary version strings in the form: // - 1.2-release-arch // - 1.2.3-release-arch // - 1.2.3.4-release-arch // - 1.2-alpha3-release-arch // - 1.2-alpha3.4-release-arch BinaryRegex = NumberRegex + `-(?P<release>[^-]+)-(?P<arch>[^-]+)` )
Variables ¶
var Zero = Number{}
Zero is occasionally convenient and readable. Please don't change its value.
Functions ¶
Types ¶
type Binary ¶
Binary specifies a binary version of juju.v
func MustParseBinary ¶
MustParseBinary parses a binary version and panics if it does not parse correctly.
func ParseBinary ¶
ParseBinary parses a binary version of the form "1.2.3-series-arch".
func (Binary) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Binary) MarshalYAML ¶
MarshalYAML implements yaml.v2.Marshaller interface.
func (*Binary) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Binary) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaller interface.
type Number ¶
Number represents a version number.
func Parse ¶
Parse a version in strict mode. The following version patterns are accepted:
1.2.3 (major, minor, patch) 1.2-tag3 (major, minor, patch, tag) 1.2.3.4 (major, minor, patch, build) 1.2-tag3.4 (major, minor, patch, build)
The ParseNonStrict function can be used instead to parse a wider range of version patterns (e.g. major only, major/minor etc.).
func ParseNonStrict ¶
ParseNonStrict attempts to parse a version in non-strict mode. It supports the same patterns as Parse with the addition of some extra patterns that are not considered pure semantic version values.
The following version patterns are accepted:
1 (major) 1.2 (major, minor) 1.2.3 (major, minor, patch) 1.2-tag (major, minor, tag) 1.2-tag3 (major, minor, patch, tag) 1.2.3.4 (major, minor, patch, build) 1.2-tag3.4 (major, minor, patch, build)
func (Number) Compare ¶
Compare returns -1, 0 or 1 depending on whether n is less than, equal to or greater than other. The comparison compares Major, then Minor, then Patch, then Build, using the first difference as
func (Number) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Number) MarshalYAML ¶
MarshalYAML implements yaml.v2.Marshaller interface
func (Number) ToPatch ¶
ToPatch returns back a semver Number (Major.Minor.Tag.Patch), without a build attached to the Number. In some scenarios it's prefable to not have the build number to identity a version and instead use a less qualified Number. Being less specific about exactness allows us to be more flexible about compatible with other versions.
func (*Number) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Number) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaller interface