aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2022-08-30 16:39:27 -0700
committerGitHub <noreply@github.com>2022-08-30 16:39:27 -0700
commit6606d4d51e3239f038565f525940ac6043aff53e (patch)
treed1732c169d4a2460d9c42af5b490e10735568110
parentf36a68d19a9bca43e070954ab9170a8305662d15 (diff)
downloadgo-cmp-6606d4d51e3239f038565f525940ac6043aff53e.tar.gz
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 <neild@users.noreply.github.com>
-rw-r--r--cmp/path.go4
1 files 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 "<nil>"
}
- 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 }