vendor: Update vendor logic

This commit is contained in:
Clayton Coleman 2020-04-08 14:34:43 -04:00
parent c6ac5cbc87
commit 4ca64b85f0
No known key found for this signature in database
GPG key ID: 3D16906B4F1C5CB3
1540 changed files with 265304 additions and 91616 deletions

View file

@ -35,6 +35,40 @@ func (fp Path) String() string {
return strings.Join(strs, "")
}
// Equals returns true if the two paths are equivalent.
func (fp Path) Equals(fp2 Path) bool {
return !fp.Less(fp2) && !fp2.Less(fp)
}
// Less provides a lexical order for Paths.
func (fp Path) Less(rhs Path) bool {
i := 0
for {
if i >= len(fp) && i >= len(rhs) {
// Paths are the same length and all items are equal.
return false
}
if i >= len(fp) {
// LHS is shorter.
return true
}
if i >= len(rhs) {
// RHS is shorter.
return false
}
if fp[i].Less(rhs[i]) {
// LHS is less; return
return true
}
if rhs[i].Less(fp[i]) {
// RHS is less; return
return false
}
// The items are equal; continue.
i++
}
}
func (fp Path) Copy() Path {
new := make(Path, len(fp))
copy(new, fp)
@ -54,8 +88,8 @@ func MakePath(parts ...interface{}) (Path, error) {
fp = append(fp, PathElement{Index: &t})
case string:
fp = append(fp, PathElement{FieldName: &t})
case []value.Field:
if len(t) == 0 {
case *value.FieldList:
if len(*t) == 0 {
return nil, fmt.Errorf("associative list key type path elements must have at least one key (got zero)")
}
fp = append(fp, PathElement{Key: t})