Skip to content

Conversation

@antonlau-1
Copy link
Contributor

When discussing best practices for Go's error packages, the current examples define static sentinel errors using fmt.Errorf().

I believe this is undesirable for two reasons:

  • Misleading intent. Using fmt.Errorf() without format verbs suggests formatting is occurring when it is not, causing readers to look for format verbs that do not exist.
  • Unnecessary dependency. fmt is a large formatting package. For truly static errors, there is no reason to import it when errors.New() is designed for this use case.

This change clarifies the separation of concerns: errors.New() for static error declarations,fmt.Errorf() when formatting is actually needed.

@antonlau-1
Copy link
Contributor Author

Ran locally to check the displayed output.

Screenshot 2025-10-09 at 00 31 45

@eliben
Copy link
Collaborator

eliben commented Oct 9, 2025

Thanks

@eliben eliben merged commit 981a575 into mmcgrana:master Oct 9, 2025
2 checks passed
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.

2 participants