You are describing a thread-local variable (or a goroutine local variable, I suppose). The Go authors didn't feel this was an appropriate feature for Go and it is not supported.
You may find some third party libraries that do this by parsing stack traces and using them to index into maps or similar techniques, but these could break at any moment and you should avoid them at all costs. —Sam On Sat, May 23, 2020, at 15:34, adithyasasha...@gmail.com wrote: > Is there a way to create a global variable inside go routine stack? so > that i can access any time, without passing around between > methods/functions. Crazy thought !!!.. -- Sam Whited -- 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/b4ed0a33-b538-499a-8753-13388b9a58f6%40www.fastmail.com.