Standard library / runtime
runtime.CallersFrames()
Creates an iterator that resolves return PCs into logical frames, taking inlined calls into account. Use only the initialized slice. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func CallersFrames(callers []uintptr) *FramesParameters & Attributes
| Name | Type | Description |
|---|---|---|
| callers | []uintptr | Initialized return PCs from Callers; do not mutate during iteration. |
Return Value
*Frames
Iterator over logical call frames.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { pcs := make([]uintptr, 16) n := runtime.Callers(1, pcs) f, _ := runtime.CallersFrames(pcs[:n]).Next() fmt.Println(f.Function != "")}