|
|
|
|
|
by richardsondrew
1465 days ago
|
|
> However, the issue this brings up about structs / types not explicitly declaring which interfaces they implement is a real and unaddressed problem You can do this with a line of code below the struct definition, something like: var _ <interface> = &<struct>{}
The compiler will also generate helpful errors if the struct doesn't implement the interface.Not requiring struct definition is a great feature in golang. I'm able to add an interface to a struct defined in another library to inject a different implementation for unit tests. |
|