Skip to content

fix: error-strings custom funcs overwrites defaults #1249

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

Merged
merged 3 commits into from
Feb 26, 2025

Conversation

alexandear
Copy link
Collaborator

The PR fixes a bug in the error-strings rule where configuring custom functions overwrites default functions.

When configuring custom functions to ["errors.Wrap"], the internal map r.errorFunctions would be:

	r.errorFunctions = map[string]map[string]struct{}{
		"fmt": {
			"Errorf": {},
		},
		"errors": {
			"Wrap": {},
		},
	}

but it should be:

	r.errorFunctions = map[string]map[string]struct{}{
		"fmt": {
			"Errorf": {},
		},
		"errors": {
			"Errorf":       {},
			"WithMessage":  {},
			"Wrap":         {},
			"New":          {},
			"WithMessagef": {},
			"Wrapf":        {},
		},
	}

Fixes #1243

@chavacava chavacava merged commit 67d0a61 into mgechev:master Feb 26, 2025
8 checks passed
@alexandear alexandear deleted the fix/error-strings-custom-std branch February 26, 2025 21:29
mfederowicz pushed a commit to mfederowicz/revive that referenced this pull request Apr 18, 2025
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.

error-strings does not allow multiple functions for the same package
3 participants