Re:Just Fucking Use Go
by avanai on Friday May 08, 2026 @10:14AM
(#48063526)
Now your compiler will tell you you stopped implementing the interface. Pretty? No. But it works. And gopls will even offer to implement stubs for missing methods.
[ Parent
| on HN ]
Re:Just Fucking Use Go
by BadBadJellyBean on Friday May 08, 2026 @11:18AM
(#48064400)
That is helpful but I think that is still a fail for Go. This could and should be a simple annotation.
Re:Just Fucking Use Go
by pdmccormick on Friday May 08, 2026 @01:51PM
(#48066487)
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.
Re:Just Fucking Use Go
by BadBadJellyBean on Friday May 08, 2026 @05:57PM
(#48069282)
This 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.