When printing with Sdump, we sometimes see these pointer comments:
and so on... This makes it more difficult to diff. Here's a workaround, but it would be nice to have an option to disable them:
pattern := regexp.MustCompile(`\ \/\/\ p[0-9]+$`) // the p0, p1 comments...
clean := func(s string) string {
lines := []string{}
for _, line := range strings.Split(s, "\n") {
s := pattern.ReplaceAllLiteralString(line, "")
lines = append(lines, s)
}
return strings.Join(lines, "\n")
}
lo1 := clean(lo.Sdump(exp))
lo2 := clean(lo.Sdump(ast))
if lo1 == lo2 { // simple diff
return
}
I use this to diff two AST's in tests in https://github.com/purpleidea/mgmt/
Thanks!