4 ms·
This problem is solved in most languages by wrapping endpoint code in an interceptor that creates and cleans up the transaction for you. I'm not a fan of Go be
by throwaway189262 6y ago
This problem is solved in most languages by wrapping endpoint code in an interceptor that creates and cleans up the transaction for you.
I'm not a fan of Go because it encourages hacks like this. The language is not expressive enough to handle database transactions properly. So it's suggested to try to catch bad situations with a linter instead.
What a timeless Goland solution to the problem. They should put "fix it with a linter" on hats and sell them at Go rallies. You could make billions
- morelisp 6y ago> an interceptor that creates and cleans up the transaction for you. I'm not sure about the word "interceptor" here because in Go and every other language I know which does this it is merely a wrapper, but Go does this. From some vantage, the problem only arises because Go does this - if it instead forced you to create a transaction the resource allocation, and so possibility of exhaustion, would be a lot more obvious.