I'm trying to Turn off echoing in the terminal, in the Golang,
Code:
func main() {
STDINFILE := os.Stdin
STDINFILENO := 0
raw, err := unix.IoctlGetTermios(STDINFILENO, unix.TCGETA)
if err != nil {
panic(err)
}
rawState := *raw
rawState.Lflag &^= unix.ECHO
err = unix.IoctlSetTermios(STDINFILENO, unix.TCSAFLUSH, &rawState)
if err != nil {
panic(err)
}
var charValue byte
reader := bufio.NewReader(STDINFILE)
for {
var err error
// read one byte
charValue, err = reader.ReadByte()
if err != nil {
if err == io.EOF {
fmt.Println("END OF FILE")
}
}
// press q to quit.
if charValue == 'q' {
os.Exit(0)
}
}
}
But it's not working as expected
I'm still able to see the echoed value,
What I'm doing wrong, Can someone please point out to me or guide me?