Skip to content

Commit

Permalink
Use value.TypeString in PathStep.String
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
  • Loading branch information
dsnet committed Aug 8, 2022
1 parent 14ad8a0 commit 78130f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmp/path.go
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 78130f9

Please sign in to comment.