Re: [go-nuts] runtime.Caller ->

2016-08-16 Thread Chris Hines
There was some discussion about how to handle generated methods in stack traces in #11432, in particular I brought it up in this comment: https://github.com/golang/go/issues/11432#issuecomment-146269822. The discussion eventually led to the addition of the new runtime.CallersFrames API, but

Re: [go-nuts] runtime.Caller ->

2016-08-15 Thread Ian Lance Taylor
On Mon, Aug 15, 2016 at 10:51 AM, Tim Hockin wrote: > OK, is there ANY heuristic I can rely on find the "real" call frame? I don't know. Sorry. As I said earlier, I don't have a good answer here. You should open an issue for this. For some reason it has not been a

Re: [go-nuts] runtime.Caller ->

2016-08-15 Thread 'Tim Hockin' via golang-nuts
OK, is there ANY heuristic I can rely on find the "real" call frame? On Mon, Aug 15, 2016 at 10:17 AM, Ian Lance Taylor wrote: > On Sun, Aug 14, 2016 at 10:07 PM, Tim Hockin wrote: >> Can I rely on "" not changing? > > I'm sorry, that's a hard question to

Re: [go-nuts] runtime.Caller ->

2016-08-15 Thread Ian Lance Taylor
On Sun, Aug 14, 2016 at 10:07 PM, Tim Hockin wrote: > Can I rely on "" not changing? I'm sorry, that's a hard question to answer, because other compilers do not use that string. There are no plans to change that string for the gc toolchain. Ian > On Sun, Aug 14, 2016 at

Re: [go-nuts] runtime.Caller ->

2016-08-14 Thread Dave Cheney
The autogenerated miranda method only happens if you are calling through an interface method that is provided by an embedded type. If you're doing something like func log(...) { pc := runtime.Callers(1) // get the caller of log } It shouldn't be a problem. On Monday, 15 August 2016

Re: [go-nuts] runtime.Caller ->

2016-08-14 Thread 'Tim Hockin' via golang-nuts
On Sun, Aug 14, 2016 at 8:31 PM, Ian Lance Taylor wrote: > On Sun, Aug 14, 2016 at 3:33 PM, Tim Hockin wrote: >> Edit: It looks like this has more to do with being an interface >> method than an embedded type. >> >> https://play.golang.org/p/I5XPdWR_O0 > >

Re: [go-nuts] runtime.Caller ->

2016-08-14 Thread 'Tim Hockin' via golang-nuts
Edit: It looks like this has more to do with being an interface method than an embedded type. https://play.golang.org/p/I5XPdWR_O0 Is there a generic way to get the caller safely, or should I just check for and increment? On Sun, Aug 14, 2016 at 3:02 PM, Tim Hockin wrote:

Re: [go-nuts] runtime.Caller ->

2016-08-14 Thread 'Tim Hockin' via golang-nuts
It is, in fact, a method on an embedded type. That means I can document it and it ceases to be a magic number! Thanks. On Aug 14, 2016 12:27 PM, "Ian Lance Taylor" wrote: > On Sun, Aug 14, 2016 at 11:10 AM, 'Tim Hockin' via golang-nuts > wrote:

Re: [go-nuts] runtime.Caller ->

2016-08-14 Thread Ian Lance Taylor
On Sun, Aug 14, 2016 at 11:10 AM, 'Tim Hockin' via golang-nuts wrote: > I was playing with a method that wants to print the file:line of the > caller. `runtime.Caller(1)` seems like it should do the trick, but I > get ':2'. If I call `runtime.Caller(2)` instead it

[go-nuts] runtime.Caller ->

2016-08-14 Thread 'Tim Hockin' via golang-nuts
I was playing with a method that wants to print the file:line of the caller. `runtime.Caller(1)` seems like it should do the trick, but I get ':2'. If I call `runtime.Caller(2)` instead it seems to work, but I don't know why, so I am reluctant to depend on that. Can anyone enlighten me? How