Reputation: 79
As with fmt.Stringer, the fmt
package looks for the error interface when printing values. In case if a type satisfies both interfaces, fmt
only on look for error
not Stringer
. Why? How I could implement both Stringer
and error
on a type?
Upvotes: 2
Views: 1315
Reputation: 21
Not really a universal solution, but in certain situations one can use pointer vs non-pointer receivers to do the trick: https://play.golang.org/p/DY4Cq4efsT
Upvotes: 2