Closed 1995parham closed 3 years ago
We already have the -ignoreNames
flag, but I think for cases like this it's not quite enough. It would be better to have a new flag that also allows to specify the exact type of the variable to ignore.
I've added the -ignoreDecls
flag that allows to ignore arbitrary variable declarations, for example:
-ignoreDecls 'c echo.Context, f *foo.Bar, t testing.T'
Please note that this does not work if the analyzer can't directly determine a variable's type, for example in this statement:
c := context.Background()
I think it should be possible to analyze type information if the analyzer is running inside golangci-lint, but I have not worked on that yet.
varnamelen 0.6.0 can now infer types of expressions (see #10). For example, for a statement like this
c := context.Background()
it is now able to infer the type of c
.
some HTTP frameworks like echo have context which is different from go context and sometimes we need to have them both so using the variable name
c
is a pattern for them.I don't know how, but it would be great if we can consider this for popular frameworks.