You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
434 B

  1. // +build windows
  2. // +build !appengine
  3. package isatty
  4. import (
  5. "syscall"
  6. "unsafe"
  7. )
  8. var kernel32 = syscall.NewLazyDLL("kernel32.dll")
  9. var procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
  10. // IsTerminal return true if the file descriptor is terminal.
  11. func IsTerminal(fd uintptr) bool {
  12. var st uint32
  13. r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
  14. return r != 0 && e == 0
  15. }