We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I would like to be able call a function to close my sqlx.Stmt structs to reduce dublicate code using a function like:
func closer(aStruct io.Closer) { err := aStruct.Close() if err != nil { logrus.Warnf("error closing sqlx statement %v", err) } }
statement, err := db.Preparex(findUserOptions) defer closer(statement)
But the version of sqlclosecheck in golangci-lint v1.30 will throw an error because it thinks I'm not closing the struct
pkg/database/client.go:174:34: Rows/Stmt was not closed (sqlclosecheck) statement, err := c.db.Preparex(findUserOptions)
If you think this feature is possible and worthwhile I'm interested in working on it
The text was updated successfully, but these errors were encountered:
I will see what I can do.
Sorry, something went wrong.
Is there any estimate when this can be fixed?
big +1 this would help us too, we are wrapping the Close function in a helper function with signature db.CloseResource(ctx, resource)
db.CloseResource(ctx, resource)
This would be nice for some code I maintain, because I, too, have a wrapper function - log.Close(resource) - and my choices are to either do:
log.Close(resource)
rows, err := tx.Query(query) if err != nil { return err } defer rows.Close()
which causes a lint issue with errcheck because the error return isn't being checked, or:
errcheck
rows, err := tx.Query(query) if err != nil { return err } defer log.Close(rows)
which causes this lint "issue" to appear.
I will spend some time on this project over the next few weeks. I will take a look at this.
No branches or pull requests
I would like to be able call a function to close my sqlx.Stmt structs to reduce dublicate code using a function like:
But the version of sqlclosecheck in golangci-lint v1.30 will throw an error because it thinks I'm not closing the struct
pkg/database/client.go:174:34: Rows/Stmt was not closed (sqlclosecheck) statement, err := c.db.Preparex(findUserOptions)
If you think this feature is possible and worthwhile I'm interested in working on it
The text was updated successfully, but these errors were encountered: