golint: docs

This commit is contained in:
Daisuke Maki 2014-07-12 16:11:42 +09:00
parent c2e61912f2
commit ea41547c16
3 changed files with 9 additions and 0 deletions

View file

@ -7,15 +7,18 @@ import (
"unsafe"
)
// IsTty checks if the given fd is a tty
func IsTty(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGETA), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}
// TtyReady checks if the tty is ready to go
func TtyReady() error {
return nil
}
// TtyTerm restores any state, if necessary
func TtyTerm() {
}

View file

@ -7,15 +7,18 @@ import (
"unsafe"
)
// IsTty checks if the given fd is a tty
func IsTty(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}
// TtyReady checks if the tty is ready to go
func TtyReady() error {
return nil
}
// TtyTerm restores any state, if necessary
func TtyTerm() {
}

View file

@ -28,6 +28,7 @@ func setStdHandle(stdhandle int32, handle syscall.Handle) error {
return nil
}
// IsTty checks if the given fd is a tty
func IsTty(fd uintptr) bool {
f := syscall.MustLoadDLL("kernel32.dll").MustFindProc("GetConsoleMode")
var st uint32
@ -38,6 +39,7 @@ func IsTty(fd uintptr) bool {
var stdout = os.Stdout
var stdin = os.Stdin
// TtyReady checks if the tty is ready to go
func TtyReady() error {
var err error
_stdin, err := os.Open("CONIN$")
@ -69,6 +71,7 @@ func TtyReady() error {
return nil
}
// TtyTerm restores any state, if necessary
func TtyTerm() {
os.Stdin = stdin
syscall.Stdin = syscall.Handle(os.Stdin.Fd())