Skip to content

Commit

Permalink
semantic: add forked reflect based DeepEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Feb 7, 2019
1 parent a326ccf commit 47bdc18
Show file tree
Hide file tree
Showing 4 changed files with 571 additions and 0 deletions.
30 changes: 30 additions & 0 deletions semantic/deep_equal.go
@@ -0,0 +1,30 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package semantic

import (
"k8s.io/utils/third_party/forked/golang/reflect"
)

// Equalities is a map from type to a function comparing two values of
// that type.
type Equalities = reflect.Equalities

// EqualitiesOrDie adds the given funcs and panics on any error.
func EqualitiesOrDie(funcs ...interface{}) Equalities {
return reflect.EqualitiesOrDie(funcs...)
}
6 changes: 6 additions & 0 deletions third_party/forked/golang/reflect/README.md
@@ -0,0 +1,6 @@
This was originally forked from https://github.com/golang/go/blob/master/src/reflect/deepequal.go in order to

- consider empty lists and empty maps equal to their nil counterparts
- add a `AddFuncs` mechanism to add custom equality funcs for specific types.

Meanwhile it has diverged quite a lot while still following the original algorithm at the core though.

0 comments on commit 47bdc18

Please sign in to comment.