color

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 3 Imported by: 3

Documentation

Overview

Package color provides functions for printing in different colors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color interface {
	Black(format string, a ...interface{}) string
	Red(format string, a ...interface{}) string
	Green(format string, a ...interface{}) string
	Yellow(format string, a ...interface{}) string
	Blue(format string, a ...interface{}) string
	Magenta(format string, a ...interface{}) string
	Cyan(format string, a ...interface{}) string
	White(format string, a ...interface{}) string
	DefaultColor(format string, a ...interface{}) string
	WithColor(code ColorCode, format string, a ...interface{}) string
	Enabled() bool
}

Color provides an interface for a color or monochrome type that will be returned by NewColor() based on whether coloring is enabled or not.

func NewColor

func NewColor(enableColor EnableColor) Color

NewColor returns a color or monochrome type depending on the value of enableColor. A monochrome type will always return the string in the default color.

type ColorCode

type ColorCode int

ColorCode represents the int used for coloring formatted strings in a certain color.

const (
	BlackFg ColorCode = iota + 30
	RedFg
	GreenFg
	YellowFg
	BlueFg
	MagentaFg
	CyanFg
	WhiteFg
	DefaultFg
)

Foreground text colors

type Colorfn

type Colorfn func(format string, a ...interface{}) string

Colorfn is a function type that takes a formatted string and returns it in a certain color.

type EnableColor

type EnableColor int

EnableColor represents whether or not to return colored strings.

const (
	ColorNever EnableColor = iota
	ColorAuto
	ColorAlways
)

func (*EnableColor) Set

func (ec *EnableColor) Set(s string) error

Set sets the EnableColor type based on the string value.

func (*EnableColor) String

func (ec *EnableColor) String() string

String returns the string value of the EnableColor type.

Jump to

Keyboard shortcuts

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