OneBug This week's bugs
Spot the bug Go
1
package main
2
 
3
import (
4
	"fmt"
5
	"unicode/utf8"
6
)
7
 
8
// Summarize a display name: its character count and whether it fits the 4-char limit.
9
func summarize(name string) (int, bool) {
10
	chars := utf8.RuneCountInString(name)
11
	fits := len(name) <= 4
12
	return chars, fits
13
}
14
 
15
func main() {
16
	fmt.Println(summarize("café"))
17
	// expected: 4 true, actual: 4 false  (!)
18
}

Read the full write-up for this bug (spoilers)