Standard library / runtime
runtime.Pinner.Pin()
Pins the referenced Go object; pointers contained within it are not automatically pinned. Use Unpin to release pins. Expected stdout: 'pinned\n'.
Formal Syntax & Structure
go syntaxgo
func (p *Pinner) Pin(pointer any)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| pointer | any | Pointer to the object to pin, not an integer address. |
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") }