You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type Test struct {
ID int64 `diff:"id,identifier"`
Bool bool `diff:"bool"`
Test string `diff:"test"`
}
a := []Test{{ID: 1, Bool: true, Test: "Bool set to true"}}
b := []Test{{ID: 2, Bool: false, Test: "Bool set to false"}}
changelog, err := diff.Diff(a, b)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v\n", changelog)
Gives:
{Type:create Path:[2 id] From:<nil> To:2 parent:<nil>} {Type:create Path:[2 test] From:<nil> To:Bool set to false parent:<nil>}]
Field Bool is missing from create. Should also have:
package main
import (
"fmt"
"github.com/r3labs/diff"
)
func main() {
type Whatever struct {
Enabled bool
}
old := map[string]Whatever{"in-errors": {false}}
new := map[string]Whatever{}
changes, err := diff.Diff(old, new)
if err != nil {
fmt.Printf("error diffing old (%#v) and new (%#v): %s", old, new, err.Error())
return
}
fmt.Printf("differences from old (%#v) to new (%#v): %#v", old, new, changes)
}
which produces:
differences from old (map[string]main.Whatever{"in-errors":main.Whatever{Enabled:false}}) to new (map[string]main.Whatever{}): diff.Changelog(nil)
Hi
Test code using go 1.20:
Gives:
Field Bool is missing from create. Should also have:
Any help is appreciated!
Thanks.
The text was updated successfully, but these errors were encountered: