Help us shape the future of Go! Take the 2026 Go Developer Survey

termui

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package termui decides whether human-readable output may use terminal styling (ANSI color, live progress). It is presentation only: callers never style machine-readable output, and the decision is local to one process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Color

func Color(w io.Writer, mode Mode, getenv func(string) string) bool

Color reports whether output to w may carry ANSI styling. An explicit always or never wins; in auto mode NO_COLOR disables color, FORCE_COLOR or CLICOLOR_FORCE enables it, TERM=dumb disables it, and otherwise only a terminal that accepts escape sequences gets color.

func IsTerminal

func IsTerminal(w any) bool

IsTerminal reports whether w is an interactive terminal. Pipes, files, buffers and /dev/null are not.

func Live

func Live(w io.Writer, getenv func(string) string) bool

Live reports whether w can show transient progress lines that are rewritten in place: a real terminal, not a pipe or a CI log.

Types

type Mode

type Mode string

Mode is the --color setting.

const (
	Auto   Mode = "auto"
	Always Mode = "always"
	Never  Mode = "never"
)

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode accepts auto, always or never.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL