github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2013/go1.1/scanner2.go (about)

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"bufio"
     7  	"fmt"
     8  	"log"
     9  	"strings"
    10  )
    11  
    12  func main() {
    13  	// START OMIT
    14  	const input = "Now is the winter of our discontent..."
    15  	scanner := bufio.NewScanner(strings.NewReader(input))
    16  	scanner.Split(bufio.ScanWords) // HL
    17  	count := 0
    18  	for scanner.Scan() {
    19  		count++
    20  	}
    21  	if err := scanner.Err(); err != nil {
    22  		log.Fatal(err)
    23  	}
    24  	fmt.Println(count)
    25  	// STOP OMIT
    26  }