The purpose of the interface is not to say much. However, this does not mean that interfaces can be used in any situation, and it is important to know that there is a big difference between calling through an interface and ordinary calling. First, dynamic binding can be much worse than static bindings, and second, the runtime requires additional overhead, such as an interface that replicates objects, even if it is just a pointer, adding a target on the heap that needs to be processed by GC.
Obviously, with the pressure of the internal components, the interface is not worth the candle.
Compare the assembly instructions of the interface call and the normal call, in order to have an intuitive understanding.
The normal call is inline, but the interface call has no such treatment.
Even within Ifacecall, calls need to be made through interface-related mechanisms.
Well, more details about the interface are not what this article needs to elaborate. Anyway, it's not bad to do more testing before you make any choices.
Latest news, please scan the code attention
Go Performance Optimization Tips 7/10