Unsafe — Go typing lesson

Bypassing type safety.

What you'll practice

The `unsafe` package allows you to bypass Go's type safety.

  • Here be dragons! Use only when absolutely necessary.

Pro Access Required

This is a premium lesson. Upgrade to Pro to unlock this interactive exercise and continue your learning journey.

💻Go

Unsafe

0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
4
5
6
7
8
9
10
11
12
package main↵
import (↵
"fmt"↵
"unsafe"↵
)↵
func main() {↵
i := 10↵
p := &i↵
var fp *float64 = (*float64)(unsafe.Pointer(p))↵
↵
fmt.Println(*fp)↵
}
0 / 164
Press This!
👇
`~
1!
2@
3#
4$
5%
6^
7&
8*
9(
0)
-_
=+
⌫
⇥
Q
W
E
R
T
Y
U
I
O
P
[{
]}
\|
⇪
A
S
D
F
G
H
J
K
L
;:
'"
↵
⇧
Z
X
C
V
B
N
M
,<
.>
/?
⇧
Thumb
Index
Middle
Ring
Pinky