go-errorlint
go-errorlint copied to clipboard
Not all of the issues about comparing err with gorm.ErrRecordNotFound using '==' directly can be detected by errorlint.
Version of golangci-lint:golangci-lint has version 1.44.2 built from d58dbde on 2022-02-17T18:35:00Z
Version of Go:v1.14
Issue: Not all of the issues about comparing err with gorm.ErrRecordNotFound using '==' directly can be detected by errorlint.
For example:
err := gorm.DB.First(&model).Error
if err == gorm.ErrRecordNotFound{
//...
}
The code above cannot be detected by errorlint.
I do not seem to be able to reproduce this:
package main
import "gorm.io/gorm"
type MyModel struct {
ID int
}
func main() {
db, _ := gorm.Open(nil, nil)
var model MyModel
err := db.First(&model).Error
if err == gorm.ErrRecordNotFound {
//...
}
}
It works fine.
golangci-lint also reports it. Could you update your linter to v1.45.2?