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
Since the + and - lines are the same, this is not very helpful. It would be nice if Diff would show the actual differences. Here is the code (also on the Go Playground):
package main
import (
"fmt"
"strconv"
"strings"
"github.com/google/go-cmp/cmp"
)
type Integer int64
type Array []interface{}
func (x Array) String() string {
res := []string{}
res = append(res, "Array")
res = append(res, strconv.FormatInt(int64(len(x)), 10)+" elements")
return "<" + strings.Join(res, ", ") + ">"
}
func main() {
a := Array{Integer(0), Array{float64(1), float64(2), float64(3)}}
b := Array{Integer(0), Array{Integer(1), Integer(2), Integer(3)}}
fmt.Println(cmp.Diff(a, b))
}
The text was updated successfully, but these errors were encountered:
Thanks for the concise report and reproduction. This suggest that the reporter should check if the String() output of an adjacent difference is identical. If so, to re-format the sub-value to ignore the String method.
In the code below,
Diff
shows the following "differences" between two data structures:Since the
+
and-
lines are the same, this is not very helpful. It would be nice ifDiff
would show the actual differences. Here is the code (also on the Go Playground):The text was updated successfully, but these errors were encountered: