From 6606d4d51e3239f038565f525940ac6043aff53e Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Tue, 30 Aug 2022 16:39:27 -0700 Subject: [PATCH] Use value.TypeString in PathStep.String (#306) The value.TypeString function is what the rest of the package uses and is slightly cleaner than using reflect.Type.String. Updates #305 Co-authored-by: Damien Neil --- cmp/path.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmp/path.go b/cmp/path.go index 557c7f2..a0a5885 100644 --- a/cmp/path.go +++ b/cmp/path.go @@ -161,7 +161,7 @@ func (ps pathStep) String() string { if ps.typ == nil { return "" } - s := ps.typ.String() + s := value.TypeString(ps.typ, false) if s == "" || strings.ContainsAny(s, "{}\n") { return "root" // Type too simple or complex to print } @@ -284,7 +284,7 @@ type typeAssertion struct { func (ta TypeAssertion) Type() reflect.Type { return ta.typ } func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy } -func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", ta.typ) } +func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", value.TypeString(ta.typ, false)) } // Transform is a transformation from the parent type to the current type. type Transform struct{ *transform }