Search⌘ K
AI Features

Solution: Counting Unicode Characters

Explore how to implement counting of Unicode characters, words, and lines in a Go command-line program. Understand the use of scanners, setting split types for different counts, and incrementing counters to produce accurate results in real-world applications.

We'll cover the following...

Solution explanation

We start with a scanner, which is used to read text from a reader (such as files):

Go (1.6.2)
scanner := bufio.NewScanner(r)

If the ...