-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Proposal: prefer %q
to format strings over %s
#185
Comments
+1, definitely want to encourage |
yuxincs
changed the title
Proposal: prefer
Proposal: prefer Jun 5, 2023
%q
to format strings instead of %s
%q
to format strings over %s
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I learned this from one of @abhinav's amazing talks, and thought we could probably add this practice to this doc.
Whenever formatting messages that contain a string component via
fmt
, prefer%q
instead of%s
. This will wrap the specified string in quotes, helping it stand out from the rest of the error message. More importantly, if the string is empty, it will provide a more helpful error message.The text was updated successfully, but these errors were encountered: