output

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Human

func Human(w io.Writer, res speedtest.Result, st *Styler)

Human writes a clean, colored, human-readable summary of the result to w. Pass NewStyler(false) for plain output.

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether f refers to a character device (a terminal).

func JSON

func JSON(w io.Writer, res speedtest.Result) error

JSON writes the result as a single-line JSON object to w.

func NewProgressPrinter

func NewProgressPrinter(w io.Writer, animate bool) speedtest.ProgressFunc

NewProgressPrinter returns a ProgressFunc that renders a live, single-line spinner + auto-scaling bar + throughput to w. When animate is false it produces no output. The bar scales to the peak Mbps seen so far in the current phase; a phase change finalizes the previous line with a newline.

func ShouldColor

func ShouldColor(isTTY, noColorFlag bool, noColorEnv string) bool

ShouldColor reports whether colored/animated output should be used. noColorEnv is the raw value of the NO_COLOR environment variable; per the NO_COLOR convention, any non-empty value disables color.

Types

type Styler

type Styler struct {
	// contains filtered or unexported fields
}

Styler wraps text in ANSI color codes when enabled, or returns it unchanged.

func NewStyler

func NewStyler(enabled bool) *Styler

NewStyler returns a Styler that emits color codes only when enabled.

func (*Styler) Bold

func (s *Styler) Bold(text string) string

func (*Styler) Cyan

func (s *Styler) Cyan(text string) string

func (*Styler) Dim

func (s *Styler) Dim(text string) string

func (*Styler) Green

func (s *Styler) Green(text string) string

Jump to

Keyboard shortcuts

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