I have RESTFUL web service in Golang and I'm using it's SQL driver for database. my question is should I use SQL functions with context as parameter or without it? For instance, there are both QueryContext and Query methods.
Actually I do know what is the context in Go, I just don't know why I should send it to the database methods.
Context aware methods allow for cancellable query execution.
The way the cancellation is handled is driver specific, but even if the driver is not directly supports taking the context any query that was started with a context should be closed when the context is closed.
This should help with potential connection leaks and query specific timeouts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With