On Wednesday, April 11, 2018 at 5:31:55 AM UTC-4, Kaveh Shahbazian wrote: > > The code resides here <https://play.golang.org/p/dFdNelsMSQo>. > > The output from the program is: > > NaClMain [ info ] 23:00:00 main.go:13: main.main started > NaClMain [ info ] 23:00:00 main.go:13: main.compute1 started > NaClMain [ info ] 23:00:00 main.go:13: main.compute2 started > NaClMain [ info ] 23:00:00 main.go:27: main.compute2 took 10ms > NaClMain [ info ] 23:00:00 main.go:22: main.compute1 took 20ms > NaClMain [ info ] 23:00:00 main.go:15: main.main took 20ms > > Program exited. > > The problem is the expected line number in first three lines is 37. But it > is 13. > I failed to understand why this is happening since log.Println internally > relies on runtime.Caller > > Note: I am aware that there is a logical bug in my code since the intended > first three lines were 13, 18 and 25 - but that does not affects the > expectations of the issue at hand. >
I think the issue is that the parameters to your inflog.Println() routine are evaluated and stored when you execute defer. https://golang.org/ref/spec#Defer_statements -- 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.