Based on nos answer.
Although it is technically possible there are reasons not to trust the code you wrote. Garbage collection will use the memory you point to (with string).
Take a look at result of the following code.
package main
import(
"fmt"
"strconv"
"reflect"
"unsafe"
)
func produce() string {
i := uint64(23473824)
ip := &i
str := fmt.Sprintf("%v", ip)
fmt.Println(i, ip, str)
return str
}
func main() {
str := produce()
for i := 0; i < 10; i++ {
x := make([]int, 1024*1024)
x[0] = i
}
u, _ := strconv.ParseUint(str, 0, 64)
ip := (*uint64)(unsafe.Pointer(uintptr(u)))
fmt.Println(ip,*ip, reflect.TypeOf(u)) // u is uint64, how to get pointer out of this value?
}
https://play.golang.org/p/85XOhsMTf3