Original post

I have a (production) REST API written in golang1.13 with gorilla/mux v1.7.3.

I don’t really need (at the moment) requests cancellation/with a timeout so every time I needed to pass a context to some function – I just use the same ctx variable in my package, that is defined in the func init() as:

ctx := context.Background()

For example, I have a package that is using the Azure SDK to perform some functionalities. Every method that the Azure SDK has, I need to pass a context, so I pass the ctx above.

So I have a REST API that every request sometimes uses the above functionalities.

  1. I don’t understand if this is bad/good at all, or considered good/bad practice.
  2. And the most important question – this currently seems to work. Can it go wrong?