Go

Go

Made by DeepSource

Redundant conversion between string and []byte CRT-A0007

Anti-pattern
Major
Autofix

Conversion between string and []byte is not required here, and it is better to pass the string as copy's argument as it is without type conversing it to []byte.

The builtin function copy takes care of byte to string (or vice-versa) conversion of the args passed, and hence, does not require that an explicit conversion be done when passing the arguments. Hence, the conversion can be omitted.

Bad practice

copy(b, []byte(s))

Recommended

copy(b, s)