Is there a Go interface in the standard library with:
String() string
?
(Similar to how Java has toString() on java.lang.Object)
Perhaps I just didn't search enough but I didn't see one. Wanted to use one that already exists rather than than making my own (though I guess it really makes no difference with Go's type system).
fmt.Stringer
is what you're after.
type Stringer interface {
String() string
}
The closest thing I've seen to Java's toString
is fmt#Stringer.