13 lines
264 B
Go
Raw Normal View History

2025-02-16 17:28:10 +01:00
//go:build windows
2024-03-12 00:25:20 +01:00
package tty
2025-02-11 12:19:55 +01:00
import "golang.org/x/sys/windows"
2024-03-12 00:25:20 +01:00
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
2025-02-11 12:19:55 +01:00
var mode uint32
err := windows.GetConsoleMode(windows.Handle(fd), &mode)
return err == nil
2024-03-12 00:25:20 +01:00
}