func (tio *TermSettings) Raw() error {
	C.cfmakeraw(&tio.current)
	return tio.Apply()
}
Raw sets the terminal to a very minimal raw mode suitable for simulating a
terminal emulator or doing raw line editing.

The changes are applied immediately.

I recommend this being done early on in main() and having a deferred call to
tio.Reset so that the changes will be reverted when everything exits
cleanly.
package termios
import (
	"fmt"
	"syscall"
	"unsafe"
)
import "C"
type (
	inMode    C.tcflag_t
	outMode   C.tcflag_t
	ctlMode   C.tcflag_t
	locMode   C.tcflag_t
	charIndex C.cc_t
)
const (
	IGNBRK  inMode = C.IGNBRK   
	BRKINT  inMode = C.BRKINT   
	IGNPAR  inMode = C.IGNPAR   
	PARMRK  inMode = C.PARMRK   
	INPCK   inMode = C.INPCK    
	ISTRIP  inMode = C.ISTRIP   
	INLCR   inMode = C.INLCR    
	IGNCR   inMode = C.IGNCR    
	ICRNL   inMode = C.ICRNL    
	IXON    inMode = C.IXON     
	IXOFF   inMode = C.IXOFF    
	IXANY   inMode = C.IXANY    
	IMAXBEL inMode = C.IMAXBEL  
	IUTF8   inMode = C.IUTF8    
)
const (
	OPOST  outMode = C.OPOST   
	ONLCR  outMode = C.ONLCR   
	OCRNL  outMode = C.OCRNL   
	ONOCR  outMode = C.ONOCR   
	ONLRET outMode = C.ONLRET  
	OFILL  outMode = C.OFILL   
	NLDLY  outMode = C.NLDLY   
	TABDLY outMode = C.TABDLY  
	CRDLY  outMode = C.CRDLY   
	FFDLY  outMode = C.FFDLY   
	BSDLY  outMode = C.BSDLY   
	VTDLY  outMode = C.VTDLY   
	OFDEL  outMode = C.OFDEL   
)
const (
	CSIZE  ctlMode = C.CSIZE   
	CS6    ctlMode = C.CS6     
	CS7    ctlMode = C.CS7     
	CS8    ctlMode = C.CS8     
	CSTOPB ctlMode = C.CSTOPB  
	CREAD  ctlMode = C.CREAD   
	PARENB ctlMode = C.PARENB  
	PARODD ctlMode = C.PARODD  
	HUPCL  ctlMode = C.HUPCL   
	CLOCAL ctlMode = C.CLOCAL  
)
const (
	ECHOKE  locMode = C.ECHOKE   
	ECHOE   locMode = C.ECHOE    
	ECHOK   locMode = C.ECHOK    
	ECHO    locMode = C.ECHO     
	ECHONL  locMode = C.ECHONL   
	ECHOPRT locMode = C.ECHOPRT  
	ECHOCTL locMode = C.ECHOCTL  
	ISIG    locMode = C.ISIG     
	ICANON  locMode = C.ICANON   
	IEXTEN  locMode = C.IEXTEN   
	EXTPROC locMode = C.EXTPROC  
	TOSTOP  locMode = C.TOSTOP   
	FLUSHO  locMode = C.FLUSHO   
	PENDIN  locMode = C.PENDIN   
	NOFLSH  locMode = C.NOFLSH   
)
const (
	VEOF     charIndex = C.VEOF      
	VEOL     charIndex = C.VEOL      
	VEOL2    charIndex = C.VEOL2     
	VERASE   charIndex = C.VERASE    
	VWERASE  charIndex = C.VWERASE   
	VKILL    charIndex = C.VKILL     
	VREPRINT charIndex = C.VREPRINT  
	VINTR    charIndex = C.VINTR     
	VQUIT    charIndex = C.VQUIT     
	VSUSP    charIndex = C.VSUSP     
	VSTART   charIndex = C.VSTART    
	VSTOP    charIndex = C.VSTOP     
	VLNEXT   charIndex = C.VLNEXT    
	VDISCARD charIndex = C.VDISCARD  
	VMIN     charIndex = C.VMIN      
	VTIME    charIndex = C.VTIME     
	NCC      charIndex = C.NCCS      
)
type TermSettings struct {
	fd       int
	original C.struct_termios
	current  C.struct_termios
}
func NewTermSettings(fd int) (*TermSettings, error) {
	tio := &TermSettings{fd: fd}
	if ret, errno := C.tcgetattr(C.int(fd), &tio.current); ret != 0 {
		return nil, errno
	}
	tio.original = tio.current
	return tio, nil
}
func (tio *TermSettings) Char(idx charIndex) rune {
	return rune(tio.current.c_cc[int(idx)])
}
func (tio *TermSettings) String() string {
	return fmt.Sprintf(`Terminal[%d]:
  Input   = 0x%X
  Output  = 0x%X
  Control = 0x%X
  Local   = 0x%X
  Chars   = %v
`,
		tio.fd,
		tio.current.c_iflag,
		tio.current.c_oflag,
		tio.current.c_cflag,
		tio.current.c_lflag,
		tio.current.c_cc)
}
func (tio *TermSettings) GetSize() (width, height int, err error) {
	var ws C.struct_winsize
	_, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL,
		uintptr(tio.fd),
		uintptr(syscall.TIOCGWINSZ),
		uintptr(unsafe.Pointer(&ws)))
	if errno != 0 {
		return 0, 0, syscall.Errno(errno)
	}
	height = int(ws.ws_row)
	width = int(ws.ws_col)
	return
}