skip to content
Alvin Lucillo

Go len(string)

/ 1 min read

💻 Tech

In Go, the len function when used with a string value actually returns the number of bytes used to store the string in UTF-8 encoding, not the number of characters. The reason for the design is performance. It’s much easier to work internally with bytes rather than having conversions between bytes and characters.