Open jimmyfrasche opened 4 days ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
The issue here is that the formatting done to turn the code into an example changes its behavior: when run as a test, the stack includes these functions:
runtime.Callers
runtime_test.ExampleFrames.func1
runtime_test.ExampleFrames.func2
runtime_test.ExampleFrames.func3
runtime_test.ExampleFrames
testing.runExample
testing.runExamples
testing.(*M).Run
runtime_test.TestMain
main.main
but when the documentation Example is run as shown, the stack instead has these functions:
runtime.Callers
main.main.func1
main.main.func2
main.main.func3
main.main
runtime.main
runtime.goexit
Doing a replace-all from "main.main" to "runtime_test.ExampleFrames" before printing each line of output, and breaking after "main.main" is seen, should fix it.
Go version
go version go1.23.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Run the example at https://pkg.go.dev/runtime#example-Frames
What did you see happen?
It outputs only
- more:true | runtime.Callers
Commenting out the check that
frame.File
contains"runtime/"
shows the missing frames and more.What did you expect to see?
The same output that the example shows before it is run: