thanks , I also google blew links. It is called goroutine local storage (gls) and many third party implement(https://github.com/jtolds/gls) however, the golang official suggest to use go context. but, very few document mention , how to do it as goroutine local storage . Can anyone give an example to solve my problem , refer the code I attached?
在 2019年6月19日星期三 UTC+8上午11:03:59,Kurtis Rader写道: > > On Tue, Jun 18, 2019 at 7:56 PM hui zhang <fastf...@gmail.com > <javascript:>> wrote: > >> >> is there a goroutine scope global veriable ? so I can do this ? >> > > You're asking if Go supports the equivalent of thread local storage as > used in Java, C++, and Python. The answer is, no. See > https://stackoverflow.com/questions/31932945/does-go-have-something-like-threadlocal-from-java > and https://github.com/golang/go/issues/21355 > <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fgolang%2Fgo%2Fissues%2F21355&sa=D&sntz=1&usg=AFQjCNELmaTzdMd_Zeyro6a5KDMC9HO6Sg> > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- 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/a06da5ca-4967-4697-bfbe-e043a838844d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.