Golangci-lint: errcheck issue isn't reported

Created on 3 Sep 2019  路  4Comments  路  Source: golangci/golangci-lint

It is expected to get an errcheck lint error in the following program.
errcheck reports but golangci-lint doesn't.

package main

import (
    "fmt"
    "os"
)

func main() {
    os.Setenv("test", "some_value")
    fmt.Println("no lint error")
}

Please include the following information:

  1. Version of golangci-lint:
    1.17.1
  1. Config file: cat .golangci.yml
    https://gist.github.com/ferhatelmas/62bbfdb744316f24a9d207c5bac0bcf7

  2. Go environment: go version && go env
    https://gist.github.com/ferhatelmas/d85e9c6dc8ce7850da37e641c87f283f

  3. Verbose output of running: golangci-lint run -v
    https://gist.github.com/ferhatelmas/4b92c91cff8456d21084494c849970f7

bug dependencies false negative

Most helpful comment

This looks like the expected behavior of exclusion EXC0001:

[~/tmp] [pts/0]% golangci-lint run --help
...
      --exclude-use-default            Use or not use default excludes:
                                         # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
                                         - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked

Running with option --exclude-use-default=false shows the error on os.Setenv:

[~/tmp] [pts/0]% golangci-lint run --exclude-use-default=false main.go
main.go:9:11: Error return value of `os.Setenv` is not checked (errcheck)
        os.Setenv("test", "some_value")

You can also just re-include EXC0001 in .golangci.yml:

issues:
  include:
    - EXC0001

It looks like errcheck itself excludes the check on fmt.Print*.

All 4 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Poking this issue to keep it open. I鈥檓 also having this issue

This looks like the expected behavior of exclusion EXC0001:

[~/tmp] [pts/0]% golangci-lint run --help
...
      --exclude-use-default            Use or not use default excludes:
                                         # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
                                         - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked

Running with option --exclude-use-default=false shows the error on os.Setenv:

[~/tmp] [pts/0]% golangci-lint run --exclude-use-default=false main.go
main.go:9:11: Error return value of `os.Setenv` is not checked (errcheck)
        os.Setenv("test", "some_value")

You can also just re-include EXC0001 in .golangci.yml:

issues:
  include:
    - EXC0001

It looks like errcheck itself excludes the check on fmt.Print*.

Please re-include EXC0001 for this check.
Closing for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bacongobbler picture bacongobbler  路  4Comments

jirfag picture jirfag  路  3Comments

cyriltovena picture cyriltovena  路  5Comments

kipply picture kipply  路  4Comments

lnshi picture lnshi  路  4Comments