RosettaCodeData/Task/Input-loop/Go/input-loop-1.go

27 lines
370 B
Go

package main
import (
"bufio"
"io"
"log"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
for {
s, err := in.ReadString('\n')
if err != nil {
// io.EOF is expected, anything else
// should be handled/reported
if err != io.EOF {
log.Fatal(err)
}
break
}
// Do something with the line of text
// in string variable s.
_ = s
}
}