Search code examples
govisual-studio-codegolint

Golint: some issues can detect by VSCode but not command line


There are many lint issues that VSCode, which uses Golint behind can detect but the command-line version of golint cannot. Hence CI/CD tools cannot detect all issues. For example the following code:

ctx, _ := context.WithTimeout(context.Background(), timeout)

VSCode will have the warning:

the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak

But when I run the command-line version of Golint, it cannot detect. I wonder if Golint has some configurations behind but found none.


Solution

  • This error message comes from golangci/govet, one of the activated by default linters of golangci/golangci-lint.

    I mean I have set up it using golint

    This is different from golint (golang/lint), which does not include that check.