Go Tidbit: Ellipsize Strings Without Breaking Unicode

from blog Blog on hjr265.me, | ↗ original
Strings in Go support Unicode. If you come from a programming language like C, you may think of strings as an array of (byte-sized) characters. In Go, you can convert a string to a byte slice, and access/manipulate each byte. But if you want to truncate or ellipsize the string to a specific length, you have to think of a string like a slice of...