summaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-04-09 08:04:51 +0000
committerGitHub <noreply@github.com>2021-04-09 08:04:51 +0000
commit14375f35ee00c16327edcd0f5883cc66810fc7db (patch)
treed904edbc6162b8eddc563476614d03dd1eee75ed /vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
parent4efac1f76012c35122bca7c8feebc33141fc47d3 (diff)
downloadpodman-14375f35ee00c16327edcd0f5883cc66810fc7db.tar.gz
podman-14375f35ee00c16327edcd0f5883cc66810fc7db.tar.bz2
podman-14375f35ee00c16327edcd0f5883cc66810fc7db.zip
Bump k8s.io/api from 0.20.5 to 0.21.0
Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.20.5 to 0.21.0. - [Release notes](https://github.com/kubernetes/api/releases) - [Commits](https://github.com/kubernetes/api/compare/v0.20.5...v0.21.0) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/google/go-cmp/cmp/internal/value/zero.go')
-rw-r--r--vendor/github.com/google/go-cmp/cmp/internal/value/zero.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go b/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
new file mode 100644
index 000000000..9147a2997
--- /dev/null
+++ b/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
@@ -0,0 +1,48 @@
+// Copyright 2017, The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package value
+
+import (
+ "math"
+ "reflect"
+)
+
+// IsZero reports whether v is the zero value.
+// This does not rely on Interface and so can be used on unexported fields.
+func IsZero(v reflect.Value) bool {
+ switch v.Kind() {
+ case reflect.Bool:
+ return v.Bool() == false
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return v.Int() == 0
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return v.Uint() == 0
+ case reflect.Float32, reflect.Float64:
+ return math.Float64bits(v.Float()) == 0
+ case reflect.Complex64, reflect.Complex128:
+ return math.Float64bits(real(v.Complex())) == 0 && math.Float64bits(imag(v.Complex())) == 0
+ case reflect.String:
+ return v.String() == ""
+ case reflect.UnsafePointer:
+ return v.Pointer() == 0
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
+ return v.IsNil()
+ case reflect.Array:
+ for i := 0; i < v.Len(); i++ {
+ if !IsZero(v.Index(i)) {
+ return false
+ }
+ }
+ return true
+ case reflect.Struct:
+ for i := 0; i < v.NumField(); i++ {
+ if !IsZero(v.Field(i)) {
+ return false
+ }
+ }
+ return true
+ }
+ return false
+}