s := make([]int, 500)
for i := range s {
s[i] = i
}
v := unsafe.Pointer(&s)
v2 := (*string)(v)
fmt.Println("v:", v)
fmt.Println("v2:", v2)
fmt.Println("*v2:", *v2)
So, when converting this unsafe.Pointer to a string, am I correct in believing that whatever happens to be in memory at that location will be interpreted as:
first 8 bytes: a pointer to the string characters (produced by the size value of my s slice, namely value 500)
next 8 bytes the length of my string (produce by the capacity value or my slice, namely 500 in this example)
When I print this string value, why does it not show me the 500 runes (whatever was inmemory converted to runes) starting at address 500 in my program’s virtual address space ?