Djarvur / go-err113

Golang linter to check the errors handling expressions
MIT License
45 stars 4 forks source link

Non-standard errors package not being ignored #7

Closed jackwhelpton closed 4 years ago

jackwhelpton commented 4 years ago

The documentation explicitly states:

Note: non-standard packages, like github.com/pkg/errors are ignored complitely.

However, if I write the following code:

package main

import (
    "fmt"

    "github.com/pkg/errors"
)

func main() {
    err := errors.New("option failed")
    fmt.Println(err)
}

and execute err113 ., I see:

C:\Projects\localhost\tst\main.go:10:9: do not define dynamic errors, use wrapped static errors instead: "errors.New(\"option failed\")"

jackwhelpton commented 4 years ago

A possible fix is to use the full path when comparing imports, rather than the name. A PR here for discussion:

https://github.com/Djarvur/go-err113/pull/8

onokonem commented 4 years ago

Thank you very much

unfortunately, I can not merge your PR:

Merging is blocked
The base branch requires all commits to be signed. Learn more about signing commits. 

I can add these changes myself or you can create another PR with a signed commit. What do you prefer?

BTW, for some reason, I'm not able to add a corresponding test to the testdata. This test is not mandatory though.

jackwhelpton commented 4 years ago

Probably easier if you can apply the change, as it's such a simple one: I'll look at signing the commit for any subsequent contributions though, sorry for that.

Yeah, I hit problems trying to create a test too: I was getting errors trying to resolve the third-party errors package. I wondered about creating a sample errors package within the project hierarchy, but hadn't tried it yet.

onokonem commented 4 years ago

yes ok

onokonem commented 4 years ago

fixed with https://github.com/Djarvur/go-err113/pull/11