color

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 6 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Black

func Black() support.Printer

func Blue

func Blue() support.Printer

func CaptureOutput

func CaptureOutput(f func(w io.Writer)) string

CaptureOutput simulates capturing of os.stdout with a buffer and returns what was written to the screen

func Cyan

func Cyan() support.Printer

func Debugf

func Debugf(format string, a ...any)

func Debugln

func Debugln(a ...any)

func Default

func Default() support.Printer

func Errorf

func Errorf(format string, a ...any)

func Errorln

func Errorln(a ...any)

func Gray

func Gray() support.Printer

func Green

func Green() support.Printer

func Infof

func Infof(format string, a ...any)

func Infoln

func Infoln(a ...any)

func Magenta

func Magenta() support.Printer

func New

func New(color Color) support.Printer

New Functions to create Printer with specific color

func Print added in v1.15.0

func Print(a ...any)

Print renders color tags and prints the provided arguments without a newline.

Example:

color.Print("<suc>Hello</>, <red>World</>")

func Printf added in v1.15.0

func Printf(format string, a ...any)

Printf formats a string with the provided arguments, renders color tags, and prints the result.

Example:

color.Printf("<red>Error:</> %s\n", err)

func Printfln added in v1.15.0

func Printfln(format string, a ...any)

Printfln formats a string with the provided arguments, renders color tags, and prints the result with a newline.

Example:

color.Printfln("<success>Success:</> %s", message)

func Println added in v1.15.0

func Println(a ...any)

Println renders color tags and prints the provided arguments with a newline.

Example:

color.Println("<cyan>Welcome</>, <green>to</>, <yellow>Go</>")

func Red

func Red() support.Printer

func Sprint added in v1.15.0

func Sprint(a ...any) string

Sprint renders color tags and returns the formatted string.

Example:

result := color.Sprint("<blue>Processing...</>")

func Sprintf added in v1.15.0

func Sprintf(format string, a ...any) string

Sprintf formats a string with the provided arguments, renders color tags, and returns the formatted result.

Example:

result := color.Sprintf("<red>Error:</> %s", err)

func Sprintfln added in v1.15.0

func Sprintfln(format string, a ...any) string

Sprintfln formats a string with the provided arguments, renders color tags, and returns the formatted result with a newline.

Example:

result := color.Sprintfln("<green>Task completed:</> %s", taskName)

func Sprintln added in v1.15.0

func Sprintln(a ...any) string

Sprintln renders color tags and returns the formatted string with a newline.

Example:

result := color.Sprintln("<fg=yellow;op=bold>Loading complete.</>")

func Successf

func Successf(format string, a ...any)

func Successln

func Successln(a ...any)

func Warnf

func Warnf(format string, a ...any)

DEPRECATED: Use Warningf instead

func Warningf added in v1.15.0

func Warningf(format string, a ...any)

func Warningln added in v1.15.0

func Warningln(a ...any)

func Warnln

func Warnln(a ...any)

DEPRECATED: Use Warningln instead

func White

func White() support.Printer

func Yellow

func Yellow() support.Printer

Types

type Color

type Color uint8
const (
	FgBlack Color = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
	// FgDefault revert default FG.
	FgDefault Color = 39
)
const (
	FgDarkGray Color = iota + 90
	FgLightRed
	FgLightGreen
	FgLightYellow
	FgLightBlue
	FgLightMagenta
	FgLightCyan
	FgLightWhite
	// FgGray is an alias of FgDarkGray.
	FgGray Color = 90
)

Extra foreground color 90 - 97.

func (Color) Print

func (c Color) Print(a ...any) *support.Printer

func (Color) Printf

func (c Color) Printf(format string, a ...any) *support.Printer

func (Color) Printfln

func (c Color) Printfln(format string, a ...any) *support.Printer

func (Color) Println

func (c Color) Println(a ...any) *support.Printer

func (Color) Sprint

func (c Color) Sprint(a ...interface{}) string

func (Color) Sprintf

func (c Color) Sprintf(format string, a ...interface{}) string

func (Color) Sprintfln

func (c Color) Sprintfln(format string, a ...interface{}) string

func (Color) Sprintln

func (c Color) Sprintln(a ...interface{}) string

Jump to

Keyboard shortcuts

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