September 2017
Intermediate to advanced
466 pages
9h 33m
English
Unsafe code is Go code that bypasses the type safety and memory security of Go and requires the use of the unsafe package. You will most likely never need to use unsafe code in your Go programs but if for some strange reason you ever need to, it will probably have to do with pointers.
The example code in this subsection is saved as unsafe.go and will be presented in two parts.
The first part is as follows:
package main
import (
"fmt"
"unsafe"
)
func main() {
var value int64 = 5
var p1 = &value
var p2 = (*int32)(unsafe.Pointer(p1))
You first create a new int64 ...
Read now
Unlock full access