Go's uint is an unsigned integer type whose size follows the implementation's native word size. It suits quantities that cannot be negative, such as the number of copies of a book. section 3.2.1
Counting books
Use uint as the value type in a map counter, then increment the count for each book. A missing map entry starts at uint's zero value, so count[book]++ handles the first occurrence as well as later ones. section 3.2.1
Listing 3.12 bookworm.go: The booksCount() function
// booksCount registers all the books and their occurrences
// from the bookworms shelves.
func booksCount(bookworms []Bookworm) map[Book]uint {
count := make(map[Book]uint) #1
for _, bookworm := range bookworms { #2
for _, book := range bookworm.Books {
count[book]++ #3
}
}
return count
}
A complete booksCount function combines a map[Book]uint counter with nested range loops. section 3.2.1








