add version constraints

This commit is contained in:
Aneurin Barker Snook
2024-07-12 12:11:18 +01:00
parent cac475d2f2
commit 33d31f84be
5 changed files with 185 additions and 0 deletions
+13
View File
@@ -3,6 +3,19 @@ package version
// List is a slice of versions that implements sort.Interface.
type List []*Version
// Match tests versions against a constraint and returns a new List of matching versions only.
func (list List) Match(c *Constraint) List {
filtered := List{}
for _, v := range list {
if v.Match(c) {
filtered = append(filtered, v)
}
}
return filtered
}
func (list List) Len() int {
return len(list)
}