I'm trying to scan some commands from stdin using the standard "fmt" package
However it seems that scanf stops after the first space. Any idea how I can fix it?
var in string
for err != nil {
_, err = fmt.Scanf("%s", &in)
}
fmt.Println(in)
I found that what I needed was in the bufio.Scan package
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
return scanner.Text()
}
if err := scanner.Err(); err != nil {
fmt.Fprintln(os.Stderr, "reading standard input:", err)
}