The Go runtime does the right thing. On Friday, August 11, 2023 at 8:58:53 AM UTC-4 jake...@gmail.com wrote:
> As far as I can tell, skip works even in the face of inlined functions, at > least when used with runtime.CallersFrames(). It would be surprising to me > if it did not. Do you have any evidence to the contrary? > > On Friday, August 4, 2023 at 9:51:34 AM UTC-4 sh...@tigera.io wrote: > >> I was looking at replacing logrus with the new slog library in our >> project. I noticed that it uses runtime.Callers() with a fixed skip >> <https://cs.opensource.google/go/x/exp/+/d63ba01a:slog/logger.go;l=240> >> to collect the PC of the calling code, presumably to make it possible for >> the handler to emit line number and filename. >> >> Question is: is that sound in the face of inlining functions? I think if >> the Info method gets inlined then the skip might be too large, for example. >> >> I remember having to change similar code in our project to use >> runtime.CallersFrames in order to deal with inlining. Quite possible >> there's a way to deal with an inlined PC that I wasn't aware of, but it >> seemed wrong to me. >> >> -Shaun >> > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2b25c687-1dd3-4c15-a0b8-cc13e3ca8e43n%40googlegroups.com.