Skip to content

duplicate-trim-cutset

Detect duplicate characters in string trim cutsets.

Updated View as Markdown

Default severity: warning

strings.Trim, TrimLeft, and TrimRight interpret their second argument as a set of runes, not as a prefix or suffix. Duplicate runes have no effect and often reveal that TrimPrefix or TrimSuffix was intended.

Bad

strings.TrimLeft(value, "letter")

Good

strings.TrimPrefix(value, "prefix")
Navigation

Type to search…

↑↓ navigate↵ selectEsc close