-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database/sql: Why is errDBClosed not exported? #9947
Comments
Why should it be exported? What would you do differently? |
I would use it like in my example above. |
This would be helpful in error handling. |
IME most packages don't export their |
@chowey Why would you return nil instead of an error if the select fails? I'm looking for a bit more context, if you don't mind. |
I'll explain my specific use case, so it is not so abstract. I run a cooking process periodically on a separate goroutine. Occasionally this fails because of transaction locks, etc. My default behavior is to simply log the error and then retry during the next cook period. When the program is asked to stop, I issue a The current way I deal with it is to wrap Specifically I wouldn't return a nil instead of an error. The code looks more like this (or would look like this if
|
My reading of the You might try something like this, where all your workers can select on a timer or a
|
I'm certainly not arguing that there is no other way around this problem. My question simply was, why is errDBClosed not exported? Edit: Specifically, it seems to have been created with this commit: 41c5d8d#diff-ab2cf91bbf4757084fddc5afa8bf8f07R602 It looks like prior to this, the error was being reported using |
It is not exported because code is not supposed to check for it. |
When I close a database connection and then try to execute a query on it, I get
errDBClosed
defined here:http://golang.org/src/database/sql/sql.go#L630
Why is this variable not exported? It can be useful to do something like this:
The cost of exporting this variable is nothing.
The text was updated successfully, but these errors were encountered: