Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confusing error message with SA5001 #1489

Open
chrispickard opened this issue Jan 10, 2024 · 0 comments
Open

confusing error message with SA5001 #1489

chrispickard opened this issue Jan 10, 2024 · 0 comments

Comments

@chrispickard
Copy link

	r, err := gzip.NewReader(file)
	defer r.Close() // this outputs file.go:123:2: should check returned error before deferring r.Close() (SA5001)
	if err != nil {
		log.Fatalf("error: %s", err)
	}

the error message is a little confusing because it looked to me like it was saying that I needed to check the error from defer r.Close() rather than what it actually meant which is that I needed to check the error from gzip.NewReader before attempting to close

staticcheck version: staticcheck 2023.1.6 (v0.4.6)
staticcheck debug version:

staticcheck 2023.1.6 (v0.4.6)

Compiled with Go version: go1.21.5
Main module:
	honnef.co/go/tools
Dependencies:
	github.com/BurntSushi/toml@v1.2.1
	golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a
	golang.org/x/mod@v0.12.0
	golang.org/x/sys@v0.11.0
	golang.org/x/tools@v0.12.1-0.20230825192346-2191a27a6dc5

go version: go version go1.21.0 linux/amd64

@chrispickard chrispickard added bug needs-triage Newly filed issue that needs triage labels Jan 10, 2024
@dominikh dominikh added enhancement and removed bug needs-triage Newly filed issue that needs triage labels Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants