github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/pkg/util/semver.go (about) 1 package util 2 3 import ( 4 "github.com/Masterminds/semver/v3" 5 ) 6 7 // SemverValidate validates a string ver against a string constraint 8 // Returns bool, error 9 func SemverValidate(constraint string, ver string) (bool, error) { 10 c, err := semver.NewConstraint(constraint) 11 if err != nil { 12 return false, err 13 } 14 sv, err := semver.NewVersion(ver) 15 if err != nil { 16 return false, err 17 } 18 match, _ := c.Validate(sv) 19 return match, nil 20 }