-
Notifications
You must be signed in to change notification settings - Fork 9
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
Find uses of Rows.Err when Rows is an interface #23
Conversation
@jingyugao could we merge this? |
r.rowsTyp = types.NewPointer(resNamed) | ||
r.skipFile = map[*ast.File]bool{} | ||
|
||
for _, f := range funcs { | ||
if r.noImportedDBSQL(f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete? This will cost more time on lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned it in the description of the PR.
for the github.com/jackc/pgx
library that is commonly used for PostgreSQL, db/sql
usually isn’t imported, so that noImportedDBSQL
check was preventing the linter from seeing files with incorrect code.
In a lot of cases in my code, jackc/pgx
isn’t even imported directly into files that are using those connections… it is just indirectly imported by accessing a connection pool object that is in another package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check if it importgithub.com/jackc/pgx
library?
|
||
for i := 0; i < res.Len(); i++ { | ||
flag = flag || types.Identical(res.At(i).Type(), r.rowsTyp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think line 93 should have same change. Otherwise for a function return pgx.Rows
and it doesn't close the row, the lint will make it will make false positive
Could you plz add some test case for this change? |
I was attempting to use
rowserrcheck
withgithub.com/jackc/pgx/v4
, and it didn't seem to be working. I started debugging the code, and I found a solution that seems to work.github.com/jackc/pgx/v4.Rows
is aninterface
instead of a concretestruct
type, so I updated the code to support that as best as I could.I also had to update the
go.mod
/go.sum
files to get things to work with Go 1.16 code that I'm working on.EDIT:
noImportedDBSQL
seemed to be excluding files that needed to be checked.jackc/pgx
is rarely imported in the same files that need to callrows.Err()
.