Request for update(if possible)
Author: ShockYoungCHNCreated May 13, 2023Updated May 13, 2023
After so many years, seems go compiler optimization have changed a lot. One problem is in chapter 2, iface.go, chapter 2. To make the assembly code call the function through itab func pointer,
func main() {
m := Mather(Adder{id: 6754})
// This call just makes sure that the interface is actually used.
// Without this call, the linker would see that the interface defined above
// is in fact never used, and thus would optimize it out of the final
// executable.
m.Add(10, 32)
}should be changed to
func main() {
var m Mather
m = Adder{id: 6754}
// This call just makes sure that the interface is actually used.
// Without this call, the linker would see that the interface defined above
// is in fact never used, and thus would optimize it out of the final
// executable.
m.Add(10, 32)
}Or the assembly code would CALL "".Adder.Add(SB) directly.
Source: teh-cmc/go-internals