isatty_bsd.go

 1//go:build (darwin || freebsd || openbsd || netbsd || dragonfly || hurd) && !appengine && !tinygo
 2// +build darwin freebsd openbsd netbsd dragonfly hurd
 3// +build !appengine
 4// +build !tinygo
 5
 6package isatty
 7
 8import "golang.org/x/sys/unix"
 9
10// IsTerminal return true if the file descriptor is terminal.
11func IsTerminal(fd uintptr) bool {
12	_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
13	return err == nil
14}
15
16// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
17// terminal. This is also always false on this environment.
18func IsCygwinTerminal(fd uintptr) bool {
19	return false
20}