color

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColoredOutput will check if color escape codes should be printed. This can be changed
	// for testing to an arbitrary method.
	ColoredOutput = coloredOutput
	// IsTerminal will check if the specified output stream is a terminal. This can be changed
	// for testing to an arbitrary method.
	IsTerminal = isTerminal
	// NoColor allow to force to not output colors.
	NoColor = false
)
View Source
var (
	LightRed    = Color(91)
	LightGreen  = Color(92)
	LightYellow = Color(93)
	LightBlue   = Color(94)
	LightPurple = Color(95)
	Red         = Color(31)
	Green       = Color(32)
	Yellow      = Color(33)
	Blue        = Color(34)
	Purple      = Color(35)
	Cyan        = Color(36)
	White       = Color(37)
	// None uses ANSI escape codes to reset all formatting.
	None = Color(0)

	// Default default output color for output from container-structure-test to the user
	Default = None
)

Define some Color instances that can format text to be displayed to the terminal in color, using ANSI escape codes.

Functions

func OverwriteDefault

func OverwriteDefault(color Color)

OverwriteDefault overwrites default color

Types

type Color

type Color int

Color can be used to format text using ANSI escape codes so it can be printed to the terminal in color.

func (Color) Fprint

func (c Color) Fprint(out io.Writer, a ...interface{}) (n int, err error)

Fprint wraps the operands in c's ANSI escape codes, and outputs the result to out. If out is not a terminal, the escape codes will not be added. It returns the number of bytes written and any errors encountered.

func (Color) Fprintf

func (c Color) Fprintf(out io.Writer, format string, a ...interface{}) (n int, err error)

Fprintf applies formats according to the format specifier (and the optional interfaces provided), wraps the result in c's ANSI escape codes, and outputs the result to out, followed by a newline. If out is not a terminal, the escape codes will not be added. It returns the number of bytes written and any errors encountered.

func (Color) Fprintln

func (c Color) Fprintln(out io.Writer, a ...interface{}) (n int, err error)

Fprintln wraps the operands in c's ANSI escape codes, and outputs the result to out, followed by a newline. If out is not a terminal, the escape codes will not be added. It returns the number of bytes written and any errors encountered.

type ColoredWriteCloser

type ColoredWriteCloser struct {
	io.WriteCloser
}

ColoredWriteCloser forces printing with colors to an io.WriteCloser.

type ColoredWriter

type ColoredWriter struct {
	io.Writer
}

ColoredWriter forces printing with colors to an io.Writer.

Jump to

Keyboard shortcuts

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