github.com/klaytn/klaytn@v1.12.1/log/term/terminal_windows.go (about) 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. 5 6 //go:build windows 7 // +build windows 8 9 package term 10 11 import ( 12 "syscall" 13 "unsafe" 14 ) 15 16 var kernel32 = syscall.NewLazyDLL("kernel32.dll") 17 18 var procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 20 // IsTty returns true if the given file descriptor is a terminal. 21 func IsTty(fd uintptr) bool { 22 var st uint32 23 r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 24 return r != 0 && e == 0 25 }