@@ -0,0 +1,16 @@
+// +build darwin
+
+package isatty
+import (
+ "syscall"
+ "unsafe"
+)
+const ioctlReadTermios = syscall.TIOCGETA
+func IsTerminal(fd int) bool {
+ var termios syscall.Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
+// +build linux
+const ioctlReadTermios = syscall.TCGETS
@@ -0,0 +1,17 @@
+// +build windows
+var kernel32 = syscall.NewLazyDLL("kernel32.dll")
+var procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+ var st uint32
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
+ return r != 0 && e == 0