6 ms·
If you have a function that requires both the species and a speak message from an animal, it would make sense for the interface to have a function that returns
by psherman 12y ago
If you have a function that requires both the species and a speak message from an animal, it would make sense for the interface to have a function that returns both the species and speak strings. I think that this [0] does what you would want.
If you want to guarantee that two structs contain a set of the same required fields, I believe the best practice would be to include an anonymous field for a struct with the fields across both. [1]
[0] http://play.golang.org/p/0zMqPUicgq http://play.golang.org/p/0zMqPUicgq
[1] http://play.golang.org/p/cM3XPfitxH http://play.golang.org/p/cM3XPfitxH
- Goopplesoft 12y agoThat second one is damn interesting, didn't know you could do that. Thanks!