My advice would be to use string by default when you’re working with text. But use []byte instead if one of the following conditions applies:
-
The mutability of a []byte will significantly reduce the number of allocations needed.
-
You are dealing with an API that uses []byte, and avoiding a conversion to string will simplify your code.