Skip to content

zero-replacement-limit

Detect replacement calls with a zero limit.

Updated View as Markdown

Default severity: warning

The final argument to strings.Replace and bytes.Replace is the maximum number of replacements. Zero replaces nothing. Use a negative value or the corresponding ReplaceAll function to replace every occurrence.

Bad

strings.Replace(value, old, replacement, 0)

Good

strings.ReplaceAll(value, old, replacement)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close