Skip to content

Commit

Permalink
Merge pull request #1144 from tehsphinx/comments
Browse files Browse the repository at this point in the history
go/twofer: escape % properly where it's not a placeholder
  • Loading branch information
ErikSchierboom authored Jul 3, 2019
2 parents 9c4b8c8 + 3b172a4 commit 5af081a
Showing 1 changed file with 4 additions and 4 deletions.
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.

0 comments on commit 5af081a

Please sign in to comment.