Documentation
¶
Overview ¶
Package terminal provides terminal detection utilities.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInteractive ¶
func IsInteractive() bool
IsInteractive determines if the current process is running in an interactive terminal.
Returns true if both stdin and stdout are connected to a terminal (TTY). Returns false if either is redirected to a file or pipe.
This is useful for deciding whether to prompt the user for input or fall back to non-interactive behavior.
Example ¶
interactive := IsInteractive() // Check interactivity before deciding how to proceed _ = interactive
Example (ConditionalPrompt) ¶
var input string
if IsInteractive() {
// Prompt user
input = "user-provided-value"
} else {
// Use default
input = "default-value"
}
_ = input
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.