Performance overhead of aliases

I’m looking to answer the question: “is there any performance overhead of using interface{} vs any?”

I understand that they are semantically equivalent, but I’m interested in how this is handled. Is this only affecting the compilation process? Is any alias info included in the binary? Is there some special handling for any?

I like that any is easier on the eyes, but I’m worried it might incur some (even small) performance cost.

I don’t think what you’re worried about doesn’t exist because the standard library already uses any instead of interface{} on a large scale

@omar any is nothing but an alias for interface{}. Both compile to the same machine code. So there is no performance penalty to worry about.

2 Likes