Is Go's interface system a form of duck typing? Why or why not?
Last updated
Yes in spirit: typing is structural, so a type satisfies an interface just by having the methods (no
implementskeyword).Unlike Python, the check happens at compile time, so it is called "static duck typing" or structural typing.
Benefit: you can define an interface that an existing third-party type already satisfies without modifying it.