Just attach your pimped logger to the Context, and use some structured
logger such as github.com/go-kit/kit/log, and pass a logger.With("reqid",
reqID) specialized logger.

Way easier than hacking out the goroutine id just to have a goroutine-local
storage,
and waay more reliable - for example you can pass your Context (or just the
logger) through a channel to another (worker) goroutine, and won't lose
context information.

Debraj Manna <subharaj.ma...@gmail.com> ezt írta (időpont: 2016. dec. 15.,
Cs, 13:58):

> Exactly for the same use case as mentioned in this thread
>
> https://groups.google.com/forum/#!msg/golang-nuts/zuWWBHKn6iw/FKjTGPItzcYJ
>
> On Thu, Dec 15, 2016 at 5:44 PM, Tamás Gulácsi <tgulacs...@gmail.com>
> wrote:
>
> 2016. december 15., csütörtök 12:51:28 UTC+1 időpontban DM a következőt
> írta:
>
> I am trying to execute the cgo program as mentioned here
> <https://github.com/davecheney/junk/tree/master/id>
>
>
> That's not a cgo program there, but a Go program, which uses the gc
> compiler's affinity to compile C programs into the resulting binary.
>
> But since Go 1.5.0, that C backend is removed (the last version is 1.4.2),
> so that side effect has vanished.
>
> BTW why would you need the ID of the goroutine? That's Pandora's box, and
> frowned upon here.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/Z7qTnu3V0dI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
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