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

[Good case] Handle errors in defer #5

Open
kulti opened this issue Jun 2, 2022 · 4 comments · Fixed by #8
Open

[Good case] Handle errors in defer #5

kulti opened this issue Jun 2, 2022 · 4 comments · Fixed by #8

Comments

@kulti
Copy link

kulti commented Jun 2, 2022

I hate named returns too :)

Well, one case are good and should be allowed by linter I suppose.

func f() (retErr error) {
	err := errors.New("foo")
	defer func() {
		if retErr == nil { // <-- analyse and replace returning error
			retErr = errors.New("bar")
		}
	}()
	return err
}
@firefart
Copy link
Owner

will leave this issue open until dependabot has picked it up on the golangci-lint repo

@firefart firefart reopened this Jun 12, 2022
@firefart
Copy link
Owner

firefart commented Jun 25, 2022

TODO once v1.0.4 is merged into golangci-lint (job runs sunday):

  • update option name in golangci-lint
  • update tests in golangci-lint

Reference: golangci/golangci-lint#2915

@maratori
Copy link
Contributor

maratori commented Jun 25, 2022

Option is already added to golangci-lint (master branch)

@maratori
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants