Standard library / runtime
runtime.Callers()
Collects return program counters into a caller-provided slice. Use CallersFrames for symbolic interpretation and inlining. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Callers(skip int, pc []uintptr) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| skip | int | Number of frames to skip; zero starts at Callers itself. |
| pc | []uintptr | Destination slice for return program counters. |
Return Value
int
Number of initialized entries in pc.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { pcs := make([]uintptr, 16) n := runtime.Callers(0, pcs) fmt.Println(n > 0 && n <= len(pcs))}