因此,假设我绝对需要在 in go 的特定内存地址处存储一个值。我该怎么做。例如:0xc0000140f0


package main


import (

    "fmt"

    "unsafe"

)


func main() {

    targetAddress := 0xc0000140f0

    loc := (uintptr)(unsafe.Pointer(targetAddress))

    p := unsafe.Pointer(loc)

    var val int = *((*int)(p))

    fmt.Println("Location : ", loc, " Val :", val)

}

这将导致以下错误:


./memory.go:10:33: cannot convert targetAddress (type int) to type unsafe.Pointer