Skip to content

Commit

Permalink
Use value.TypeString in PathStep.String (#306)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dsnet and neild authored Aug 30, 2022
1 parent f36a68d commit 6606d4d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmp/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 6606d4d

Please sign in to comment.