コード例 #1
0
func processLines(done chan<- struct{}, getRx *regexp.Regexp,
	pageList safeslice.SafeSlice, lines <-chan string) {
	for line := range lines {
		if matches := getRx.FindStringSubmatch(line); matches != nil {
			pageList.Append(matches[1])
		}
	}
	done <- struct{}{}
}
コード例 #2
0
func showResults(pageList safeslice.SafeSlice) {
	list := pageList.Close()
	counts := make(map[string]int)
	for _, page := range list { // uniquify
		counts[page.(string)] += 1
	}
	for page, count := range counts {
		fmt.Printf("%8d %s\n", count, page)
	}
}