-
-
Notifications
You must be signed in to change notification settings - Fork 947
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1144 from tehsphinx/comments
go/twofer: escape % properly where it's not a placeholder
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
automated-comments/go/two-fer/use_fmt_placeholder_for_string.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
In Go people tend to prefer type-specific placeholders rather than the generic `%v`. | ||
In Go people tend to prefer type-specific placeholders rather than the generic `%%v`. | ||
There are two reasons for this. First, more specific placeholders often have additional options, | ||
for example the format `%f` for `float` values can also specify the precision: `%.2f`. | ||
The second reason is that `%v` accepts any value type. If a variable type changes during a refactoring, | ||
`%v` will print the default for that type, which might not be the desired behavior. | ||
for example the format `%%f` for `float` values can also specify the precision: `%%.2f`. | ||
The second reason is that `%%v` accepts any value type. If a variable type changes during a refactoring, | ||
`%%v` will print the default for that type, which might not be the desired behavior. | ||
A type-specific placeholder will cause the linter to complain, catching the error before it gets deployed to production. |