Если вы печатаете адреса в единообразной (шестнадцатеричной) базе, вы увидите ожидаемый результат.В текущих версиях компилятора Go gc переменные i
и pi
размещаются в куче.
Например,
package main
import "fmt"
func main() {
var i int = 20
var pi *int = &i
fmt.Printf("%x the address of i\n", &i)
fmt.Printf("%x the address of pi\n", &pi)
fmt.Printf("%x the address that pi stored\n", pi)
}
Вывод:
c00008e010 the address of i
c000090018 the address of pi
c00008e010 the address that pi stored