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

Add flag allow-error-in-defer #8

Merged
merged 1 commit into from
Jun 11, 2022
Merged

Add flag allow-error-in-defer #8

merged 1 commit into from
Jun 11, 2022

Conversation

maratori
Copy link
Contributor

@maratori maratori commented Jun 9, 2022

Add flag allow-error-in-defer. If enabled, linter doesn't complain about named error, if it is assigned inside defer.

func GoodFunc() (err error) {
	defer func() {
		err = nil
	}()
	return
}

Open question: should this flag be enabled by default? Now it's not.

Fixes #5

@firefart firefart merged commit 853036d into firefart:main Jun 11, 2022
@firefart
Copy link
Owner

awesome thanks for this PR!

@maratori maratori deleted the allow-error-in-defer branch June 11, 2022 22:07
@maratori
Copy link
Contributor Author

I'll prepare PR to add config into golangci-lint tomorrow.

@maratori
Copy link
Contributor Author

maratori commented Jun 12, 2022

I created golangci/golangci-lint#2915 (draft) and will update it after new release of nonamedreturns.

@maratori
Copy link
Contributor Author

They use dependabot and update config in it's PR (I will do it).

@firefart
Copy link
Owner

@maratori thanks I've released v1.0.2 just now: https://github.com/firefart/nonamedreturns/releases/tag/v1.0.2

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 this pull request may close these issues.

[Good case] Handle errors in defer
2 participants