Created
September 9, 2019 15:25
-
-
Save x1unix/d6c5e37eb4b610c28e79397350d66754 to your computer and use it in GitHub Desktop.
unsafe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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