Due to the strict Go types, the compiler always knows which type you pass to the len function, and therefore it moves on to another function for different types, which can be determined at compile time. In most cases, you try to get the slice length, in which case the len function should only return the len field for this slice structure (since the slice is really a structure); same for string.
Compilers have all kinds of tricks, the assembly code generated by the compiler rarely follows the same logic that you typed.
source share