A Go library to detect whether a file descriptor is a terminal (TTY) or not.
go-isatty is a Go library that detects whether a file descriptor is a terminal (TTY). It solves the problem of determining if a program is running interactively in a terminal or being used in a pipeline, allowing applications to adjust output formatting, color usage, or interactive features accordingly.
Go developers building command-line tools or applications that need to adapt behavior based on terminal presence, such as those implementing colored output, progress bars, or interactive prompts.
It provides a lightweight, cross-platform solution with specific support for Cygwin/MSYS2 terminals on Windows, making it a reliable choice over manual detection or platform-specific code.
go-isatty is a Go library that provides functions to check if a file descriptor is connected to a terminal (TTY). It is essential for command-line applications that need to adapt their behavior based on whether they are running in an interactive terminal or being piped/redirected.
IsTerminal and IsCygwinTerminal.It provides a reliable, minimal, and portable way to handle terminal detection in Go, following the Unix philosophy of doing one thing well.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports Unix-like systems and Windows with specific handling for Cygwin and MSYS2 terminals, ensuring consistent behavior across environments as highlighted in the README.
Offers intuitive functions like IsTerminal and IsCygwinTerminal, making integration straightforward, as demonstrated in the usage example.
High test coverage indicated by Codecov and Coveralls badges in the README, reducing the risk of bugs in production.
Does one thing well—terminal detection—without unnecessary features, adhering to the Unix philosophy described in the project overview.
Only detects TTY presence; lacks built-in support for terminal attributes like size, color support, or interactive features, requiring additional libraries for full CLI enhancements.
For basic terminal checks on Unix, standard Go syscalls might suffice, adding this library introduces an external dependency that could be avoided in minimal projects.
While it handles Cygwin/MSYS2, the README doesn't detail support for all Windows terminal types like modern Windows Terminal, which might need extra logic.