The types string and []byte share the same memory layout, it is a pointer to memory followed by the length (with a capacity, in the case of slices) and the actual contents. When we do a ==
comparison with slices (or strings, if that matter) the runtime issues a call to
runtime.memequal(a, b unsafe.Pointer, size uintptr) bool
This function is akin to libc’s memcmp(3).
Most compilers, such as gcc, will generate very optimized assembly for an operation like this, but it mostly boils down to: