1 // Based on ssh/terminal:
2 // Copyright 2011 The Go Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
6 // +build windows,!appengine
17 var kernel32 = syscall.NewLazyDLL("kernel32.dll")
20 procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
23 // IsTerminal returns true if stderr's file descriptor is a terminal.
24 func IsTerminal(f io.Writer) bool {
25 switch v := f.(type) {
28 r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0)
29 return r != 0 && e == 0