|
|
|
|
|
by Goopplesoft
4210 days ago
|
|
It seemed to me that interfaces have a second function of providing partial uniformity across types (not just abstracting procedures). I.e the Animal interface has a method `Speak() string` and you have a function that takes an Animal that prints something like "Animal type {species} says {speak}" you would have to define a getter on the Animal's species even though its not a really a procedure. But I see what you mean though. Thanks! |
|
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 [1] http://play.golang.org/p/cM3XPfitxH