Last Updated: May 22, 2026
The unsafe.Pointer type is Go's one approved way to convert between pointers of different types or to do raw pointer arithmetic. It looks like a normal pointer, but the compiler treats it as a wildcard: any *T can be turned into an unsafe.Pointer and any unsafe.Pointer can be turned into any *U. This chapter walks through the four conversion patterns the package documentation declares safe, the rules around uintptr, the modern unsafe.Add and unsafe.Slice helpers added in Go 1.17, and the alignment and garbage-collection hazards that cause bugs.