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

chore: use errors.New to replace fmt.Errorf with no parameters #3099

Closed
wants to merge 1 commit into from

Conversation

ChengenH
Copy link

No description provided.

Signed-off-by: ChengenH <hce19970702@gmail.com>
@p-shahi
Copy link
Member

p-shahi commented Dec 16, 2024

From reading golang docs, it seems like both of these are almost identical under the hood. Is there a good reason to switch? cc @sukunrt or @MarcoPolo

@ChengenH
Copy link
Author

From reading golang docs, it seems like both of these are almost identical under the hood. Is there a good reason to switch? cc @sukunrt or @MarcoPolo

errors.New has better performance, although slightly, since it does not involve the overhead of formatting the string. It is also more concise when there are no formatting arguments.

@marten-seemann
Copy link
Contributor

I don’t think performance in the error code path matters at all. This seems like an unsubstantiated performance claim without a benchmark.

@ChengenH ChengenH closed this Dec 16, 2024
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.

3 participants