catenacyber / perfsprint

Golang linter to use strconv
MIT License
21 stars 2 forks source link

fmt.Errorf("whatever") (no arg) could be suggested to use errors.New("whatever") #27

Closed ccoVeille closed 4 months ago

ccoVeille commented 4 months ago

Extracted from gosimple discussion

any linter that wants to suggest replacing calls to errors.New with exported error variables can do the same check for fmt.Errorf with a single argument.

Originally posted by @dominikh in https://github.com/dominikh/go-tools/issues/1550#issuecomment-2138367009

Do you think it makes sense to add it to perfsprint. Errorf is a sprintf wrapper after all

catenacyber commented 4 months ago

Is it not already the case cf -errorf option

perfsprint -h
perfsprint: Checks that fmt.Sprintf can be replaced with a faster alternative.

Usage: perfsprint [-flag] [package]

Flags:
  -V    print version and exit
...
  -errorf
        optimizes fmt.Errorf (default true)
ccoVeille commented 4 months ago

My bad, I launched my test via golangci-lint but there was a local golangci.yaml file that I didn't see, so my global golangci-lint.yaml wasn't used.

catenacyber commented 4 months ago

Glad it works as expected :-)