I'm writing a text interface in golang, and if you type while it's printing, it will interfere with the text being presented. I know "stty -echo" will stop echoing the keyboard's output and "stty echo" reenables it, but when I write functions like:
func disableKeyboard() {
c := exec.Command("stty -echo")
c.Stdout = os.Stdout
c.Run()
}
func enableKeyboard() {
c := exec.Command("stty echo")
c.Stdout = os.Stdout
c.Run()
}
these have no impact on my programs output. Is there something wrong with the way I'm sending these commands?
Something like:
disableKeyboard()
time.Sleep(time.Second)
enableKeyboard()
doesn't work. I'm using a mac currently.