Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/deelawn/deepmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
deelawn committed Nov 10, 2020
2 parents e4611c8 + 6385830 commit 23070f0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Deep Match
### A more versatile reflect.DeepEqual
---

Use this package to compare define and compare equality of values of all types. It works like reflect.DeepEqual, but allows you to set options defined by the matcher.

Use a Matcher to define how equality is determined
```
type Matcher struct {
// MaxDepth is the number of times Match can be called recursively when dealing with nested data structures.
// A value of 0 means that there is no maximum depth.
MaxDepth int
// ExcludeExported is set to true when equality checks should skip exported fields.
ExcludeExported bool
// ExcludeUnexported is set to true when equality checks should skip unexported fields.
ExcludeUnexported bool
// ExcludedFieldNames is a list of field names that should not be checked for equality. Dot separators need
// to be used to separate structure name from field name.
ExcludedFieldNames []string
}
```
#### Examples:

```
type s struct {
A int
b string
}
m := Matcher {
ExcludeUnexported: true,
}
isEqual := m.Matches(s{A: 6, b: "asdf"}, s{A: 6, b: "fdsa"})
// isEqual = true
m.ExcludeUnexported = false
isEqual = m.Matches(s{A: 6, b: "asdf"}, s{A: 6, b: "fdsa"})
// isEqual = false
m.ExcludedFieldNames = []string{"b"}
isEqual = m.Matches(s{A: 6, b: "asdf"}, s{A: 6, b: "fdsa"})
// isEqual = true
```

0 comments on commit 23070f0

Please sign in to comment.