Standard library / runtime

runtime.Pinner

Keeps Go objects pinned until Unpin. Pinning is distinct from reachability and does not remove cgo pointer restrictions. Expected stdout: 'pinned\n'.

Formal Syntax & Structure

go syntaxgo
type Pinner struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() { var p runtime.Pinner; x := new(int); p.Pin(x); defer p.Unpin(); fmt.Println("pinned") }
Go Reference