fn: fix windows port of fn

This commit is contained in:
Carlos C
2016-12-06 04:18:56 +01:00
parent 8943374705
commit ce325f2c1f

View File

@@ -10,7 +10,7 @@ import (
"unsafe"
)
func getStdin() io.Reader {
func stdin() io.Reader {
var stdin io.Reader = os.Stdin
if isTerminal(int(os.Stdin.Fd())) {
stdin = strings.NewReader("")
@@ -19,6 +19,8 @@ func getStdin() io.Reader {
}
func isTerminal(fd int) bool {
kernel32 := syscall.NewLazyDLL("kernel32.dll")
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