3 ms·
I believe they're talking about the semi-duck typing used in go for interfaces but I'm not certain. Interfaces are implicitly implemented with a runtime check d
by noah_buddy 5y ago
I believe they're talking about the semi-duck typing used in go for interfaces but I'm not certain. Interfaces are implicitly implemented with a runtime check determining whether a type x assigned to interface y is valid.This is why you'll often see an empty declaration in packages for structs intended to implement an interface like so:
var _ y = x{} // syntax might be slightly wrong
After writing this, I found the linked article in the OP link to what the author meant.
https://rakyll.org/typesystem/ https://rakyll.org/typesystem/
There's really a bunch of small things that are different about golang that individually you can find elsewhere but are on the whole unique.
- politician 5y agovar _ = ThingerInterface(&Struct{}) Creates a compile time error if Struct is not a ThingerInterface.