forked from r3labs/diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
37 lines (33 loc) · 1.04 KB
/
options.go
File metadata and controls
37 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package diff
// SliceOrdering determines whether the ordering of items in a slice results in a change
func SliceOrdering(enabled bool) func(d *Differ) error {
return func(d *Differ) error {
d.SliceOrdering = enabled
return nil
}
}
// TagName sets the tag name to use when getting field names and options
func TagName(tag string) func(d *Differ) error {
return func(d *Differ) error {
d.TagName = tag
return nil
}
}
// DisableStructValues disables populating a separate change for each item in a struct,
// where the struct is being compared to a nil value
func DisableStructValues() func(d *Differ) error {
return func(d *Differ) error {
d.DisableStructValues = true
return nil
}
}
// CustomValueDiffers allows you to register custom differs for specific types
func CustomValueDiffers(vd ...ValueDiffer) func(d *Differ) error {
return func(d *Differ) error {
d.customValueDiffers = append(d.customValueDiffers, vd...)
for k, _ := range d.customValueDiffers {
d.customValueDiffers[k].InsertParentDiffer(d.diff)
}
return nil
}
}