Skip to content

Instantly share code, notes, and snippets.

@x1unix
Created September 9, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x1unix/d6c5e37eb4b610c28e79397350d66754 to your computer and use it in GitHub Desktop.
Save x1unix/d6c5e37eb4b610c28e79397350d66754 to your computer and use it in GitHub Desktop.
unsafe
package main
import (
"fmt"
"unsafe"
)
func main() {
var mem [16*32]byte
//addr := 2
ptr := (uintptr) (unsafe.Pointer(&mem))
ptr += 2
sptr := (*rune) (unsafe.Pointer(ptr))
*sptr = 'f'
fmt.Println("Start Addr:\t", ptr)
fmt.Println("Rune Addr:\t",sptr)
fmt.Println("Result:\t", mem)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment