4 ms·
This also works: var _ MyInterface = (*MyStruct)(nil) In my mind as I read this, I am reminded that it is the receiver type *MyStruct that implements MyIn
by pdmccormick 5mo ago
This also works:
var _ MyInterface = (*MyStruct)(nil)
In my mind as I read this, I am reminded that it is the receiver type *MyStruct that implements MyInterface. YMMV.
- BadBadJellyBean 5mo agoThis is a useful hack but just imagine someone coming from another language reading this. They'd have no idea what it's for. It looks a bit like the things C people do to themselves. And all just because someone didn't want a keyword or another form of annotation to signal that a struct should implement an interface. These are the small things that annoy me about go.