4 ms·
They use hack of "interface{}" which does type checking at runtime (slow). And you then cast it to a proper type. If I remember correctly (haven't used it in a
by takeda 5y ago
They use hack of "interface{}" which does type checking at runtime (slow). And you then cast it to a proper type.
If I remember correctly (haven't used it in a year) Go cheats a bit, and it has few functions in standard library that do have generics (like make), it just doesn't provide this functionality to the developer.
- loopz 5y agoIf you can avoid interface{} you should, ie. by declaring interfaces to types and using them explicitly. You can then mix your own types, and still be protected by the type system.
- takeda 5y agoYes, but that requires generics and without them code generators (and if you don't use them, a lot of copy & paste).