August 2019
Beginner to intermediate
798 pages
17h 2m
English
Now you have seen the unsafe package in action, it is a good time to talk more about what makes it a special kind of package. First of all, if you look at the source code of the unsafe package, you might be a little surprised. On a macOS Mojave system with Go version 1.11.4 that is installed using Homebrew (https://brew.sh/), the source code of the unsafe package is located at /usr/local/Cellar/go/1.11.4/libexec/src/unsafe/unsafe.go and its contents without the comments are the following:
$ cd /usr/local/Cellar/go/1.11.4/libexec/src/unsafe/ $ grep -v '^//' unsafe.go | grep -v '^$' package unsafe type ArbitraryType int type Pointer *ArbitraryType func Sizeof(x ArbitraryType) uintptr func Offsetof(x ArbitraryType) uintptr ...
Read now
Unlock full access