"At Google, we require that Go programmers pass a Context parameter as the first argument to every function on the call path between incoming and outgoing requests. This allows Go code developed by many different teams to interoperate well. It provides simple control over timeouts and cancellation and ensures that critical values like security credentials transit Go programs properly." This is a quote from Google's documentation on context, and it says to always use context. I am facing an issue where I don't know whether to use the context passed down from Gin for critical DB operations such as user. I have been told by a lot of people to always use context, but I feel like writing user information to the database should not be canceled just because the user disconnected or the context was canceled for whatever reason. Am I wrong and I should just use context like they said? The thing that is holding me back from ditching context for this operation is that without the context the operation just runs and cannot be controlled.
If something doesn't deserve to be canceled just because the client went away, then decouple cancellation from the parent context using Context.WithoutCancel. Don't throw the context away.