• Rob Pike's avatar
    bufio: new Scanner interface · 55ad7b9b
    Rob Pike authored
    Add a new, simple interface for scanning (probably textual) data,
    based on a new type called Scanner. It does its own internal buffering,
    so should be plausibly efficient even without injecting a bufio.Reader.
    The format of the input is defined by a "split function", by default
    splitting into lines. Other implemented split functions include single
    bytes, single runes, and space-separated words.
    
    Here's the loop to scan stdin as a file of lines:
    
            s := bufio.NewScanner(os.Stdin)
            for s.Scan() {
                    fmt.Printf("%s\n", s.Bytes())
            }
            if s.Err() != nil {
                    log.Fatal(s.Err())
            }
    
    While we're dealing with spaces, define what space means to strings.Fields.
    
    Fixes #4802.
    
    R=adg, rogpeppe, bradfitz, rsc
    CC=golang-dev
    https://golang.org/cl/7322088
    55ad7b9b
Name
Last commit
Last update
..
cmd Loading commit data...
lib9 Loading commit data...
libbio Loading commit data...
libmach Loading commit data...
pkg Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...
sudo.bash Loading commit data...