package main import ( "fmt" "os" "syscall" "unsafe" ) func main() { terminal, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0) if err != nil { fmt.Println(fmt.Sprintf("error opening terminal: %s", err.Error())) return } // Go doesn't have a wrapper for any of the termios ioctls. var termios syscall.Termios if err = ioctl(terminal.Fd(), syscall.TCGETS, uintptr(unsafe.Pointer(&termios))); err != nil { fmt.Println(fmt.Sprintf("Error on get: %s", err.Error())) return } // Set -onlcr so we don't have to deal with \r. termios.Oflag &^= syscall.ONLCR if err := ioctl(terminal.Fd(), syscall.TCSETS, uintptr(unsafe.Pointer(&termios))); err != nil { fmt.Println(fmt.Sprintf("Error on set: %s", err.Error())) return } fmt.Println("No syscall error") } func ioctl(fd uintptr, flag, data uintptr) error { if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, flag, data); err != 0 { return err } return nil }