If it's not just a quick hack, I'd recommend providing the session to
the handlers via other means than global variables.
If you're using mgo with MongoDB, I also recommend copying the session
from the initial one for each handled request, and using defer
session.Close() on it so that its resources return to the pool
afterwards. This is cheap in terms of resources, and will ensure that
requests do not stumble upon each other in terms of errors and slow
downs caused by potential long running activities. It's not about
concurrency safety, though. You can safely use a single mgo session
with as many goroutines as desired.
> --
> 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...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
--
gustavo @
http://niemeyer.net