(no title)
liquidgecka | 11 months ago
Anytime you use an interface it forces a heap allocation, even if the object is only used read only and within the same scope. That includes calls to things like fmt.Printf() so doing a for loop that prints the value of i forces the integer backing i to be heap allocated, along with every other value that you printed. So if you helpfully make every api in your library use an interface you are forcing the callers to use heap allocations for every single operation.
slashdev|11 months ago
https://go.dev/play/p/zHfnQfJ9OGc
masklinn|11 months ago