Since by default all http requests coming to a go http server are on their own goroutine, I am wondering if there is a way to have some sort of "global" variable that is *local* to a goroutine if that makes sense, something like this, where "gork" is the namespace for variables available anywhere within a goroutine:
func PrintLoggedInUser(){ log.Println(gork.loggedInUser) } go func(){ var loggedInUser = "abc" PrintLoggedInUser() }() go func(){ var loggedInUser = "def" PrintLoggedInUser() }() why? i am looking to log the current logged in user id, without having to manually pass that id to every log call. log.Warn("foo") // will log: "foo", "logged in user id:", abc log.Error("bar") // will log: "bar", "logged in user id:", abc but for now, I have to pass the id manually: log.Warn(id, "foo") // will log: "foo", "logged in user id:", abc log.Error(id, "bar") // will log: "bar", "logged in user id:", abc -- 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/07fb2e73-14a2-4559-a7d6-2010acbc7c51n%40googlegroups.com.