Skip to content

byte-string-write

Detect byte slices converted to strings for io.WriteString.

Updated View as Markdown

Default severity: warning

io.WriteString(writer, string(bytes)) allocates and copies the byte slice before writing it. The writer already accepts bytes through Write, so write the original slice directly.

Bad

_, err := io.WriteString(writer, string(bytes))

Good

_, err := writer.Write(bytes)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close