Studying from “customary enter” is de facto helpful if you’re making a command-line software and require consumer enter.
bundle important
import (
"bufio"
"os"
"fmt"
)
func important() {
reader := bufio.NewReader(os.Stdin)
s, _ := reader.ReadString('n')
fmt.Printf(s)
}
First setup a brand new bufio
reader, then use ReadString
perform, with a default wait character, which now we have set to a newline (n
).
The applying will pause at this level and look ahead to consumer enter earlier than continuing.