shad-go/lectures/00-intro/uniq/uniq.go
Fedor Korotkiy 3d9a69ac37 Fix lecture
2020-02-13 15:47:08 +03:00

20 lines
303 B
Go

package main
import (
"bufio"
"fmt"
"os"
)
func main() {
counts := make(map[string]int)
input := bufio.NewScanner(os.Stdin)
for input.Scan() {
counts[input.Text()]++
}
// NOTE: ignoring potential errors from input.Err()
for line, n := range counts {
fmt.Printf("%d\t%s\n", n, line)
}
}