Hi guys,
Go interfaces define functions that must be implemented for any struct to implement that interface.
This differs from other languages where interface can also specify some fields which much be present in implementing classes/structs.
Please refer http://stackoverflow.com/questions/26027350/go-interface-fields (question and comments) for further clarification on what I mean.
Was thinking we could have something like this for types so that all type structs in the system have some common fields (for e.g., name
and description
). It’s not a necessary requirement but a good one to have, since then, we can make use of encapsulation whenever required.
Any thoughts? Have any of you encountered some scenario where you would like to have this property of interfaces?