Documentation ¶
Index ¶
- Variables
- type And
- type CompatibleWith
- type Constraint
- type Dependency
- type Equals
- type GreaterThan
- type GreaterThanOrEqual
- type LessThan
- type LessThanOrEqual
- type List
- type NormalizedString
- type Not
- type Or
- type RelaxedVersion
- func (v *RelaxedVersion) CompareTo(u *RelaxedVersion) int
- func (v *RelaxedVersion) CompatibleWith(u *RelaxedVersion) bool
- func (v *RelaxedVersion) Equal(u *RelaxedVersion) bool
- func (v *RelaxedVersion) GreaterThan(u *RelaxedVersion) bool
- func (v *RelaxedVersion) GreaterThanOrEqual(u *RelaxedVersion) bool
- func (v *RelaxedVersion) LessThan(u *RelaxedVersion) bool
- func (v *RelaxedVersion) LessThanOrEqual(u *RelaxedVersion) bool
- func (v *RelaxedVersion) MarshalBinary() ([]byte, error)
- func (v *RelaxedVersion) MarshalJSON() ([]byte, error)
- func (v *RelaxedVersion) MarshalYAML() (interface{}, error)
- func (v *RelaxedVersion) NormalizedString() NormalizedString
- func (v *RelaxedVersion) String() string
- func (v *RelaxedVersion) UnmarshalBinary(data []byte) error
- func (v *RelaxedVersion) UnmarshalJSON(data []byte) error
- func (v *RelaxedVersion) UnmarshalYAML(node *yaml.Node) error
- type Release
- type Releases
- type Resolver
- type True
- type Version
- func (v *Version) CompareTo(u *Version) int
- func (v *Version) CompatibleWith(u *Version) bool
- func (v *Version) Equal(u *Version) bool
- func (v *Version) GreaterThan(u *Version) bool
- func (v *Version) GreaterThanOrEqual(u *Version) bool
- func (v *Version) LessThan(u *Version) bool
- func (v *Version) LessThanOrEqual(u *Version) bool
- func (v *Version) MarshalBinary() ([]byte, error)
- func (v *Version) MarshalJSON() ([]byte, error)
- func (v *Version) MarshalYAML() (interface{}, error)
- func (v *Version) Normalize()
- func (v *Version) NormalizedString() NormalizedString
- func (v *Version) String() string
- func (v *Version) UnmarshalBinary(data []byte) error
- func (v *Version) UnmarshalJSON(data []byte) error
- func (v *Version) UnmarshalYAML(node *yaml.Node) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var WarnInvalidVersionWhenParsingRelaxed = false
WarnInvalidVersionWhenParsingRelaxed must be set to true to show warnings while parsing RelaxedVersion if an invalid semver string is found. This allows a soft transition to strict semver
Functions ¶
This section is empty.
Types ¶
type And ¶
type And struct {
Operands []Constraint
}
And will match if ALL the Operands Constraint will match
type CompatibleWith ¶ added in v0.10.0
type CompatibleWith struct {
Version *Version
}
CompatibleWith is the "compatible with" (^) constraint
func (*CompatibleWith) Match ¶ added in v0.10.0
func (cw *CompatibleWith) Match(v *Version) bool
Match returns true if v satisfies the condition
func (*CompatibleWith) String ¶ added in v0.10.0
func (cw *CompatibleWith) String() string
type Constraint ¶
type Constraint interface { // Match returns true if the Version satisfies the condition Match(*Version) bool String() string }
Constraint is a condition that a Version can match or not
func ParseConstraint ¶
func ParseConstraint(in string) (Constraint, error)
ParseConstraint converts a string into a Constraint. The resulting Constraint may be converted back to string using the String() method.
type Dependency ¶
type Dependency interface { GetName() string GetConstraint() Constraint }
Dependency represents a dependency, it must provide methods to return Name and Constraints
type Equals ¶
type Equals struct {
Version *Version
}
Equals is the equality (=) constraint
type GreaterThan ¶
type GreaterThan struct {
Version *Version
}
GreaterThan is the "greater than" (>) constraint
func (*GreaterThan) Match ¶
func (gt *GreaterThan) Match(v *Version) bool
Match returns true if v satisfies the condition
func (*GreaterThan) String ¶
func (gt *GreaterThan) String() string
type GreaterThanOrEqual ¶
type GreaterThanOrEqual struct {
Version *Version
}
GreaterThanOrEqual is the "greater than or equal" (>=) constraint
func (*GreaterThanOrEqual) Match ¶
func (gte *GreaterThanOrEqual) Match(v *Version) bool
Match returns true if v satisfies the condition
func (*GreaterThanOrEqual) String ¶
func (gte *GreaterThanOrEqual) String() string
type LessThan ¶
type LessThan struct {
Version *Version
}
LessThan is the less than (<) constraint
type LessThanOrEqual ¶
type LessThanOrEqual struct {
Version *Version
}
LessThanOrEqual is the "less than or equal" (<=) constraint
func (*LessThanOrEqual) Match ¶
func (lte *LessThanOrEqual) Match(v *Version) bool
Match returns true if v satisfies the condition
func (*LessThanOrEqual) String ¶
func (lte *LessThanOrEqual) String() string
type NormalizedString ¶ added in v0.10.0
type NormalizedString string
NormalizedString is a datatype to be used in maps and other places where the version is used as a key.
type Not ¶
type Not struct {
Operand Constraint
}
Not match if Operand does not match and viceversa
type Or ¶
type Or struct {
Operands []Constraint
}
Or will match if ANY of the Operands Constraint will match
type RelaxedVersion ¶
type RelaxedVersion struct {
// contains filtered or unexported fields
}
RelaxedVersion allows any possible version string. If the version does not comply with semantic versioning it is saved as-is and only Equal comparison will match.
func ParseRelaxed ¶
func ParseRelaxed(in string) *RelaxedVersion
ParseRelaxed parse a RelaxedVersion
Example ¶
WarnInvalidVersionWhenParsingRelaxed = true ParseRelaxed("bad") WarnInvalidVersionWhenParsingRelaxed = false
Output: WARNING invalid semver version bad: no major version found
func (*RelaxedVersion) CompareTo ¶
func (v *RelaxedVersion) CompareTo(u *RelaxedVersion) int
CompareTo compares the RelaxedVersion with the one passed as parameter. Returns -1, 0 or 1 if the version is respectively less than, equal or greater than the compared Version
func (*RelaxedVersion) CompatibleWith ¶ added in v0.10.0
func (v *RelaxedVersion) CompatibleWith(u *RelaxedVersion) bool
CompatibleWith returns true if the RelaxedVersion is compatible with the RelaxedVersion passed as paramater
func (*RelaxedVersion) Equal ¶
func (v *RelaxedVersion) Equal(u *RelaxedVersion) bool
Equal returns true if the RelaxedVersion is equal to the RelaxedVersion passed as parameter
func (*RelaxedVersion) GreaterThan ¶
func (v *RelaxedVersion) GreaterThan(u *RelaxedVersion) bool
GreaterThan returns true if the RelaxedVersion is greater than the RelaxedVersion passed as parameter
func (*RelaxedVersion) GreaterThanOrEqual ¶
func (v *RelaxedVersion) GreaterThanOrEqual(u *RelaxedVersion) bool
GreaterThanOrEqual returns true if the RelaxedVersion is greater than or equal to the RelaxedVersion passed as parameter
func (*RelaxedVersion) LessThan ¶
func (v *RelaxedVersion) LessThan(u *RelaxedVersion) bool
LessThan returns true if the RelaxedVersion is less than the RelaxedVersion passed as parameter
func (*RelaxedVersion) LessThanOrEqual ¶
func (v *RelaxedVersion) LessThanOrEqual(u *RelaxedVersion) bool
LessThanOrEqual returns true if the RelaxedVersion is less than or equal to the RelaxedVersion passed as parameter
func (*RelaxedVersion) MarshalBinary ¶ added in v0.10.0
func (v *RelaxedVersion) MarshalBinary() ([]byte, error)
MarshalBinary implements json.Marshaler
func (*RelaxedVersion) MarshalJSON ¶
func (v *RelaxedVersion) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (*RelaxedVersion) MarshalYAML ¶ added in v0.11.0
func (v *RelaxedVersion) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler
func (*RelaxedVersion) NormalizedString ¶ added in v0.10.0
func (v *RelaxedVersion) NormalizedString() NormalizedString
NormalizedString return a string representation of the version that is normalized (always have a major, minor and patch version when semver compliant). This is useful to be used in maps and other places where the version is used as a key.
func (*RelaxedVersion) String ¶
func (v *RelaxedVersion) String() string
func (*RelaxedVersion) UnmarshalBinary ¶ added in v0.10.0
func (v *RelaxedVersion) UnmarshalBinary(data []byte) error
UnmarshalBinary implements json.Unmarshaler
func (*RelaxedVersion) UnmarshalJSON ¶
func (v *RelaxedVersion) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler
func (*RelaxedVersion) UnmarshalYAML ¶ added in v0.11.0
func (v *RelaxedVersion) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler
type Release ¶
type Release[D Dependency] interface { GetName() string GetVersion() *Version GetDependencies() []D }
Release represents a release, it must provide methods to return Name, Version and Dependencies
type Releases ¶
type Releases[R Release[D], D Dependency] []R
Releases is a list of Release of the same package (all releases with the same Name but different Version)
func (Releases[R, D]) FilterBy ¶
func (set Releases[R, D]) FilterBy(c Constraint) Releases[R, D]
FilterBy return a subset of the Releases matching the provided Constraint
func (Releases[R, D]) SortDescent ¶
func (set Releases[R, D]) SortDescent()
SortDescent sort the Releases in this set in descending order (the lastest release is the first)
type Resolver ¶ added in v0.12.0
type Resolver[R Release[D], D Dependency] struct { // contains filtered or unexported fields }
Resolver is a container with references to all Releases to consider for dependency resolution
func NewResolver ¶ added in v0.12.0
func NewResolver[R Release[D], D Dependency]() *Resolver[R, D]
NewResolver creates a new archive
func (*Resolver[R, D]) AddRelease ¶ added in v0.12.0
func (ar *Resolver[R, D]) AddRelease(rel R)
AddRelease adds a release to this archive
func (*Resolver[R, D]) AddReleases ¶ added in v0.12.0
func (ar *Resolver[R, D]) AddReleases(rels ...R)
AddReleases adds all the releases to this archive
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version contains the results of parsed version string
func (*Version) CompareTo ¶
CompareTo compares the Version with the one passed as parameter. Returns -1, 0 or 1 if the version is respectively less than, equal or greater than the compared Version
func (*Version) CompatibleWith ¶ added in v0.10.0
CompatibleWith returns true if the Version is compatible with the version passed as paramater
func (*Version) Equal ¶
Equal returns true if the Version is equal to the Version passed as parameter
func (*Version) GreaterThan ¶
GreaterThan returns true if the Version is greater than the Version passed as parameter
func (*Version) GreaterThanOrEqual ¶
GreaterThanOrEqual returns true if the Version is greater than or equal to the Version passed as parameter
func (*Version) LessThan ¶
LessThan returns true if the Version is less than the Version passed as parameter
func (*Version) LessThanOrEqual ¶
LessThanOrEqual returns true if the Version is less than or equal to the Version passed as parameter
func (*Version) MarshalBinary ¶ added in v0.10.0
MarshalBinary implements binary custom encoding
func (*Version) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Version) MarshalYAML ¶ added in v0.11.0
MarshalYAML implements yaml.Marshaler
func (*Version) Normalize ¶
func (v *Version) Normalize()
Normalize transforms a truncated semver version in a strictly compliant semver version by adding minor and patch versions. For example: "1" is trasformed to "1.0.0" or "2.5-dev" to "2.5.0-dev"
func (*Version) NormalizedString ¶ added in v0.10.0
func (v *Version) NormalizedString() NormalizedString
NormalizedString return a string representation of the version that is normalized to always have a major, minor and patch version. This is useful to be used in maps and other places where the version is used as a key.
func (*Version) UnmarshalBinary ¶ added in v0.10.0
UnmarshalJSON implements binary custom decoding
func (*Version) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
func (*Version) UnmarshalYAML ¶ added in v0.11.0
UnmarshalYAML implements yaml.Unmarshaler