Closed OscarVanL closed 2 years ago
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Hello,
The problem seems to come from govet-v0.1.6
I will continue to investigate.
I now think this is working as intended.
The fmt package's docs say:
If the format specifier includes a %w verb with an error operand, the returned error will implement an Unwrap method returning the operand. It is invalid to include more than one %w verb or to supply it with an operand that does not implement the error interface. The %w verb is otherwise a synonym for %v.
In my use case and example, the %w verb is being passed into a custom error function, but ends up calling the normal printf function and not returning an error. In that situation, it is redundant/pointless to use the %w verb rather than using %v as no error is returned, let alone one implementing the Unwrap method.
So I would say rather than changing anything in govet, it instead highlights cases where I should've used %v instead of %w.
Welcome
Description of the problem
I have some custom printf funcs in my project. I have added these to the govet config to correctly lint the error-wrapping directive checks for these:
When using 1.42.1, there are no linting errors (expected behaviour).
After upgrading to 1.43.0, there are now govet linting errors:
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
Check an example repo I've made demonstrating the issue:
https://gitlab.com/oscar.vanleusen/golangci-lint-regression
Run these commands to replicate the problem:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
golangci-lint run --sort-results --config .golangci.yml
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0
golangci-lint run --sort-results --config .golangci.yml