TL;DR:  Is the uintptr slice returned from runtime.Callers always valid?

Reading the docs* for runtime.Callers says: "Callers fills the slice pc 
with the return program counters of function invocations on the calling 
goroutine's stack. "  Does this imply that once the goroutine is gone, or 
all the functions have returned, the uintptrs could be pointing to 
garbage?   

I ask because I would like a cheap-ish stacktrace for some error handling 
code I am writing, and I don't want to turn the stack frame into a full 
string.  If I can capture the functions on the stack and maybe turn them 
into an error message later that would be ideal.

Example (requires 1.7): https://play.golang.org/p/bfZBvcLzje

* https://tip.golang.org/pkg/runtime/#Callers

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to