unused
linter in golangci-lint reports blank (_
) identifier as unused for function parameters
#1568
Labels
unused
linter in golangci-lint reports blank (_
) identifier as unused for function parameters
#1568
The
unused
linter accepts an unnamed function parameter as used. However, if any parameter for a function is named, then all of the parameters must be named, so it is not possible to leave a parameter unnamed if the function accepts multiple parameters and only one parameter is ignored. This can happen, for example, if an interface method takes several parameters, but some implementations of the method don't need all of the parameters. The typical way to address this is to name the unused parameters with the_
identifier to indicate that they are ignored, but theunused
linter reports the_
parameters as unused when theParametersAreUsed
option is false.I did not see this issue in earlier versions, so it may be a new behavior since the AST-based rewrite. This issue is closely related to #1567.
Note that I am running this through
golangci-lint
because I couldn't figure out a way to configure theParametersAreUsed
option when callingstaticcheck
directly. The version ofgolangci-lint
I am using has a dependency on thehonnef.co/go/tools v0.4.7
module.Lint Command Output
Test Code
main.go
Source CodeDeclaring the
Repeat
implementation asRepeat(string, count int)
causes the Go compiler to try to processstring
andcount
as two parameter names that are both of typeint
, which produces the following compile error when trying to run the program:golangci-list
ConfigEnvironment Info
The text was updated successfully, but these errors were encountered: