Is there a reason why string does not implement fmt.Stringer? It seems like this would be a useful abstraction.
Is there a reason why string does not implement fmt.Stringer? It seems like this would be a useful abstraction.
For example, I would like a function that does something to an object
that can be treated as a String:
func Log(s Stringer) { ... }
But right now I would need two implementations-- one that accepts
strings and one that accepts Stringer.
--Kevin
For example, I would like a function that does something to an object
that can be treated as a String:
func Log(s Stringer) { ... }But right now I would need two implementations-- one that accepts
strings and one that accepts Stringer.
2012/3/23 Jan Mercl <0xj...@gmail.com>:
Alternatively, just have it only take a string call it like this:
Log(value.String())
Why not: func (id Identifier) String() string { return fmt.Sprint(id.id) }
fmt.Sprint takes interface{} arguments, you must have written something else.