NewConstraint will parse one or more constraints from the given constraint string. The string must be a comma-separated list of constraints.
(v string)
| 62 | // constraint string. The string must be a comma-separated list of |
| 63 | // constraints. |
| 64 | func NewConstraint(v string) (Constraints, error) { |
| 65 | vs := strings.Split(v, ",") |
| 66 | result := make([]*Constraint, len(vs)) |
| 67 | for i, single := range vs { |
| 68 | c, err := parseSingle(single) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | |
| 73 | result[i] = c |
| 74 | } |
| 75 | |
| 76 | return result, nil |
| 77 | } |
| 78 | |
| 79 | // Check tests if a version satisfies all the constraints. |
| 80 | func (cs Constraints) Check(v *Version) bool { |