Standard library / runtime
runtime.FuncForPC()
Looks up function metadata for a program counter; can return nil. For stacks, prefer CallersFrames. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func FuncForPC(pc uintptr) *FuncParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pc | uintptr | Program counter to look up. |
Return Value
*Func
Function metadata, or nil when no function is found.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { pc, _, _, ok := runtime.Caller(0); fmt.Println(ok && runtime.FuncForPC(pc) != nil) }