Am 22.07.2012 20:46, schrieb Nick Sabalausky:
On Sun, 22 Jul 2012 18:14:23 +0200 Paulo Pinto<[email protected]> wrote:y :=&x[0] fmt.Println("Base adress ", y) size := unsafe.Sizeof(x[0]) fmt.Println("Size per element ", size) for i := 0; i< len(x); i++ { cell := uint64(uintptr(unsafe.Pointer(y))) + (uint64(i) * uint64(size)) value := (*byte)(unsafe.Pointer(uintptr(cell))) fmt.Printf("%d index is %d, at %p\n", i, *value, value) } }Eeew!! That's awful.
Pointer arithmetic as endless source for security exploits is to be used *only* when no other solution exists. But yes, the way to do it could be simpler.
