// +build !windows,!plan9package termimport ()func (, *os.File) (func() error, error) {// On Unix, use input file for changing termios. All fds pointing to the // same terminal are equivalent. := int(.Fd()) , := sys.TermiosForFd()if != nil {returnnil, fmt.Errorf("can't get terminal attribute: %s", ) } := .Copy() .SetICanon(false) .SetIExten(false) .SetEcho(false) .SetVMin(1) .SetVTime(0)// Enforcing crnl translation on readline. Assuming user won't set // inlcr or -onlcr, otherwise we have to hardcode all of them here. .SetICRNL(true) = .ApplyToFd()if != nil {returnnil, fmt.Errorf("can't set up terminal attribute: %s", ) }varerror = setupVT()if != nil { = fmt.Errorf("can't setup VT: %s", ) } := func() error {returndiag.Errors(.ApplyToFd(), restoreVT()) }return , }func () func() {returnfunc() {}}func (, *os.File) {// Some programs use non-blocking IO but do not correctly clear the // non-blocking flags after exiting, so we always clear the flag. See #822 // for an example.unix.SetNonblock(int(.Fd()), false)unix.SetNonblock(int(.Fd()), false)}
The pages are generated with Goldsv0.2.8-preview. (GOOS=darwin GOARCH=arm64)