mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00

Replaces uses of the github.com/mitchellh/mapstructure module, which was deprecated by the owner and moved to new maintainership at github.com/go-viper/mapstructure. The old module is still referenced as indirect dependency (through docker/cli and theupdateframework/notary), but not used in code, and should eventually go away. full diff: https://github.com/compose-spec/compose-go/compare/v2.1.1...v2.1.2 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
45 lines
799 B
Go
45 lines
799 B
Go
//go:build !go1.20
|
|
|
|
package mapstructure
|
|
|
|
import "reflect"
|
|
|
|
func isComparable(v reflect.Value) bool {
|
|
k := v.Kind()
|
|
switch k {
|
|
case reflect.Invalid:
|
|
return false
|
|
|
|
case reflect.Array:
|
|
switch v.Type().Elem().Kind() {
|
|
case reflect.Interface, reflect.Array, reflect.Struct:
|
|
for i := 0; i < v.Type().Len(); i++ {
|
|
// if !v.Index(i).Comparable() {
|
|
if !isComparable(v.Index(i)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return v.Type().Comparable()
|
|
|
|
case reflect.Interface:
|
|
// return v.Elem().Comparable()
|
|
return isComparable(v.Elem())
|
|
|
|
case reflect.Struct:
|
|
for i := 0; i < v.NumField(); i++ {
|
|
return false
|
|
|
|
// if !v.Field(i).Comparable() {
|
|
if !isComparable(v.Field(i)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
|
|
default:
|
|
return v.Type().Comparable()
|
|
}
|
|
}
|