mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #49750 from thaJeztah/bump_go_cmp
vendor: github.com/google/go-cmp v0.7.0
This commit is contained in:
@@ -50,7 +50,7 @@ require (
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2
|
||||
github.com/golang/protobuf v1.5.4
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0
|
||||
|
||||
@@ -263,8 +263,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
|
||||
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
|
||||
64
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
64
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
@@ -14,22 +14,29 @@ import (
|
||||
)
|
||||
|
||||
// SortSlices returns a [cmp.Transformer] option that sorts all []V.
|
||||
// The less function must be of the form "func(T, T) bool" which is used to
|
||||
// sort any slice with element type V that is assignable to T.
|
||||
// The lessOrCompareFunc function must be either
|
||||
// a less function of the form "func(T, T) bool" or
|
||||
// a compare function of the format "func(T, T) int"
|
||||
// which is used to sort any slice with element type V that is assignable to T.
|
||||
//
|
||||
// The less function must be:
|
||||
// A less function must be:
|
||||
// - Deterministic: less(x, y) == less(x, y)
|
||||
// - Irreflexive: !less(x, x)
|
||||
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||
//
|
||||
// The less function does not have to be "total". That is, if !less(x, y) and
|
||||
// !less(y, x) for two elements x and y, their relative order is maintained.
|
||||
// A compare function must be:
|
||||
// - Deterministic: compare(x, y) == compare(x, y)
|
||||
// - Irreflexive: compare(x, x) == 0
|
||||
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||
//
|
||||
// The function does not have to be "total". That is, if x != y, but
|
||||
// less or compare report inequality, their relative order is maintained.
|
||||
//
|
||||
// SortSlices can be used in conjunction with [EquateEmpty].
|
||||
func SortSlices(lessFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessFunc)
|
||||
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {
|
||||
panic(fmt.Sprintf("invalid less function: %T", lessFunc))
|
||||
func SortSlices(lessOrCompareFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessOrCompareFunc)
|
||||
if (!function.IsType(vf.Type(), function.Less) && !function.IsType(vf.Type(), function.Compare)) || vf.IsNil() {
|
||||
panic(fmt.Sprintf("invalid less or compare function: %T", lessOrCompareFunc))
|
||||
}
|
||||
ss := sliceSorter{vf.Type().In(0), vf}
|
||||
return cmp.FilterValues(ss.filter, cmp.Transformer("cmpopts.SortSlices", ss.sort))
|
||||
@@ -79,28 +86,40 @@ func (ss sliceSorter) checkSort(v reflect.Value) {
|
||||
}
|
||||
func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
|
||||
vx, vy := v.Index(i), v.Index(j)
|
||||
return ss.fnc.Call([]reflect.Value{vx, vy})[0].Bool()
|
||||
vo := ss.fnc.Call([]reflect.Value{vx, vy})[0]
|
||||
if vo.Kind() == reflect.Bool {
|
||||
return vo.Bool()
|
||||
} else {
|
||||
return vo.Int() < 0
|
||||
}
|
||||
}
|
||||
|
||||
// SortMaps returns a [cmp.Transformer] option that flattens map[K]V types to be a
|
||||
// sorted []struct{K, V}. The less function must be of the form
|
||||
// "func(T, T) bool" which is used to sort any map with key K that is
|
||||
// assignable to T.
|
||||
// SortMaps returns a [cmp.Transformer] option that flattens map[K]V types to be
|
||||
// a sorted []struct{K, V}. The lessOrCompareFunc function must be either
|
||||
// a less function of the form "func(T, T) bool" or
|
||||
// a compare function of the format "func(T, T) int"
|
||||
// which is used to sort any map with key K that is assignable to T.
|
||||
//
|
||||
// Flattening the map into a slice has the property that [cmp.Equal] is able to
|
||||
// use [cmp.Comparer] options on K or the K.Equal method if it exists.
|
||||
//
|
||||
// The less function must be:
|
||||
// A less function must be:
|
||||
// - Deterministic: less(x, y) == less(x, y)
|
||||
// - Irreflexive: !less(x, x)
|
||||
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||
// - Total: if x != y, then either less(x, y) or less(y, x)
|
||||
//
|
||||
// A compare function must be:
|
||||
// - Deterministic: compare(x, y) == compare(x, y)
|
||||
// - Irreflexive: compare(x, x) == 0
|
||||
// - Transitive: if compare(x, y) < 0 and compare(y, z) < 0, then compare(x, z) < 0
|
||||
// - Total: if x != y, then compare(x, y) != 0
|
||||
//
|
||||
// SortMaps can be used in conjunction with [EquateEmpty].
|
||||
func SortMaps(lessFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessFunc)
|
||||
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {
|
||||
panic(fmt.Sprintf("invalid less function: %T", lessFunc))
|
||||
func SortMaps(lessOrCompareFunc interface{}) cmp.Option {
|
||||
vf := reflect.ValueOf(lessOrCompareFunc)
|
||||
if (!function.IsType(vf.Type(), function.Less) && !function.IsType(vf.Type(), function.Compare)) || vf.IsNil() {
|
||||
panic(fmt.Sprintf("invalid less or compare function: %T", lessOrCompareFunc))
|
||||
}
|
||||
ms := mapSorter{vf.Type().In(0), vf}
|
||||
return cmp.FilterValues(ms.filter, cmp.Transformer("cmpopts.SortMaps", ms.sort))
|
||||
@@ -143,5 +162,10 @@ func (ms mapSorter) checkSort(v reflect.Value) {
|
||||
}
|
||||
func (ms mapSorter) less(v reflect.Value, i, j int) bool {
|
||||
vx, vy := v.Index(i).Field(0), v.Index(j).Field(0)
|
||||
return ms.fnc.Call([]reflect.Value{vx, vy})[0].Bool()
|
||||
vo := ms.fnc.Call([]reflect.Value{vx, vy})[0]
|
||||
if vo.Kind() == reflect.Bool {
|
||||
return vo.Bool()
|
||||
} else {
|
||||
return vo.Int() < 0
|
||||
}
|
||||
}
|
||||
|
||||
7
vendor/github.com/google/go-cmp/cmp/internal/function/func.go
generated
vendored
7
vendor/github.com/google/go-cmp/cmp/internal/function/func.go
generated
vendored
@@ -19,6 +19,7 @@ const (
|
||||
|
||||
tbFunc // func(T) bool
|
||||
ttbFunc // func(T, T) bool
|
||||
ttiFunc // func(T, T) int
|
||||
trbFunc // func(T, R) bool
|
||||
tibFunc // func(T, I) bool
|
||||
trFunc // func(T) R
|
||||
@@ -28,11 +29,13 @@ const (
|
||||
Transformer = trFunc // func(T) R
|
||||
ValueFilter = ttbFunc // func(T, T) bool
|
||||
Less = ttbFunc // func(T, T) bool
|
||||
Compare = ttiFunc // func(T, T) int
|
||||
ValuePredicate = tbFunc // func(T) bool
|
||||
KeyValuePredicate = trbFunc // func(T, R) bool
|
||||
)
|
||||
|
||||
var boolType = reflect.TypeOf(true)
|
||||
var intType = reflect.TypeOf(0)
|
||||
|
||||
// IsType reports whether the reflect.Type is of the specified function type.
|
||||
func IsType(t reflect.Type, ft funcType) bool {
|
||||
@@ -49,6 +52,10 @@ func IsType(t reflect.Type, ft funcType) bool {
|
||||
if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType {
|
||||
return true
|
||||
}
|
||||
case ttiFunc: // func(T, T) int
|
||||
if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == intType {
|
||||
return true
|
||||
}
|
||||
case trbFunc: // func(T, R) bool
|
||||
if ni == 2 && no == 1 && t.Out(0) == boolType {
|
||||
return true
|
||||
|
||||
10
vendor/github.com/google/go-cmp/cmp/options.go
generated
vendored
10
vendor/github.com/google/go-cmp/cmp/options.go
generated
vendored
@@ -232,7 +232,15 @@ func (validator) apply(s *state, vx, vy reflect.Value) {
|
||||
if t := s.curPath.Index(-2).Type(); t.Name() != "" {
|
||||
// Named type with unexported fields.
|
||||
name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType
|
||||
if _, ok := reflect.New(t).Interface().(error); ok {
|
||||
isProtoMessage := func(t reflect.Type) bool {
|
||||
m, ok := reflect.PointerTo(t).MethodByName("ProtoReflect")
|
||||
return ok && m.Type.NumIn() == 1 && m.Type.NumOut() == 1 &&
|
||||
m.Type.Out(0).PkgPath() == "google.golang.org/protobuf/reflect/protoreflect" &&
|
||||
m.Type.Out(0).Name() == "Message"
|
||||
}
|
||||
if isProtoMessage(t) {
|
||||
help = `consider using "google.golang.org/protobuf/testing/protocmp".Transform to compare proto.Message types`
|
||||
} else if _, ok := reflect.New(t).Interface().(error); ok {
|
||||
help = "consider using cmpopts.EquateErrors to compare error values"
|
||||
} else if t.Comparable() {
|
||||
help = "consider using cmpopts.EquateComparable to compare comparable Go types"
|
||||
|
||||
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -624,8 +624,8 @@ github.com/google/certificate-transparency-go/jsonclient
|
||||
github.com/google/certificate-transparency-go/tls
|
||||
github.com/google/certificate-transparency-go/x509
|
||||
github.com/google/certificate-transparency-go/x509/pkix
|
||||
# github.com/google/go-cmp v0.6.0
|
||||
## explicit; go 1.13
|
||||
# github.com/google/go-cmp v0.7.0
|
||||
## explicit; go 1.21
|
||||
github.com/google/go-cmp/cmp
|
||||
github.com/google/go-cmp/cmp/cmpopts
|
||||
github.com/google/go-cmp/cmp/internal/diff
|
||||
|
||||
Reference in New Issue
Block a user