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

[errors] Build should return an error #892

Open
EtienneM opened this issue May 30, 2024 · 0 comments
Open

[errors] Build should return an error #892

EtienneM opened this issue May 30, 2024 · 0 comments

Comments

@EtienneM
Copy link
Member

The Build method on ValidationErrorsBuilder should return a pure error rather than a *errors.ValidationErrors:

func (v *ValidationErrorsBuilder) Build() *ValidationErrors {

The current situation may lead to a staticcheck offense never returns a nil interface value. The root cause of this issue is explained here (https://go.dev/doc/faq#nil_error):

It's a good idea for functions that return errors always to use the error type in their signature (as we did above) rather than a concrete type such as *MyError, to help guarantee the error is created correctly

Initially discussed here: https://scalingo.slack.com/archives/C01E42AT2G6/p1717062547454579

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

No branches or pull requests

1 participant