Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

False positives with custom errors-package and errors.New(fmt.Sprintf(... #350

Closed
kristofferingemansson opened this issue Oct 16, 2017 · 0 comments

Comments

@kristofferingemansson
Copy link

When using a custom errors-package implementing New(...) in conjunction with fmt.Sprintf(...) golint incorrectly suggests usage of fmt.Errorf(...) instead.
A custom errors-package will most likely return an error of different type than "errorString" of the core errors-package and hence fmt.Errorf(...) will not be equivalent.

Sample code:

import (
	"fmt"
	"github.com/pkg/errors"
)

func main() {
	errors.New(fmt.Sprintf("%v", 10))
}

Output:

main.go:9:2: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)
Found 1 lint suggestions; failing.

Expected:
No warnings

leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Dec 5, 2017
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 1, 2018
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 1, 2018
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 5, 2018
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 5, 2018
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 5, 2018
leonelquinteros added a commit to leonelquinteros/lint that referenced this issue Mar 5, 2018
@golang golang deleted a comment from jirawat050 Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant