It does seem an unnecessarily limiting convention.
What will go wrong if one stores a Context in a struct?
I've done so for a specific use case, and did not notice any issues.
> What will go wrong if one stores a Context in a struct?
Contexts are about the dynamic contour, i.e. the dynamic call stack. Storing the current context in a struct and then referring to it in some other dynamic … context … is going to lead to all sorts of pain: timeouts or deadlines which have already expired and/or values which are no longer pertinent.
While there are some limited circumstances in which it may be appropriate, in general it is a very strong code smell. Any code which passes a context should receive a context. And any code which may pass a context in the future should receive one now, to preserve API compatibility. So any exported function really should have a context as its first argument for forwards-compatibility.
This guidance is actually super important, as contexts are expected to be modified in a code flow and apply to all functions that are downstream of your current call stack.
If you store contexts on your structs it’s very likely you won’t thread them correctly, leading to errors like database code not properly handling transactions.
Actually super fragile and you should avoid doing this as much as is possible. It’s never a good idea!