aurora

package module
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Unlicense Imports: 3 Imported by: 2,341

README

Aurora

go.dev reference Unlicense Build Status Coverage Status GoReportCard Gitter

Ultimate ANSI colors for Golang. The package supports Printf/Sprintf etc.

aurora logo

TOC

Installation

Get

go get -u github.com/logrusorgru/aurora

Test

go test -cover github.com/logrusorgru/aurora

Usage

Simple
package main

import (
	"fmt"

	. "github.com/logrusorgru/aurora"
)

func main() {
	fmt.Println("Hello,", Magenta("Aurora"))
	fmt.Println(Bold(Cyan("Cya!")))
}

simple png

Printf
package main

import (
	"fmt"

	. "github.com/logrusorgru/aurora"
)

func main() {
	fmt.Printf("Got it %d times\n", Green(1240))
	fmt.Printf("PI is %+1.2e\n", Cyan(3.14))
}

printf png

aurora.Sprintf
package main

import (
	"fmt"

	. "github.com/logrusorgru/aurora"
)

func main() {
	fmt.Println(Sprintf(Magenta("Got it %d times"), Green(1240)))
}

sprintf png

Enable/Disable colors
package main

import (
	"fmt"
	"flag"

	"github.com/logrusorgru/aurora"
)

// colorizer
var au aurora.Aurora

var colors = flag.Bool("colors", false, "enable or disable colors")

func init() {
	flag.Parse()
	au = aurora.NewAurora(*colors)
}

func main() {
	// use colorizer
	fmt.Println(au.Green("Hello"))
}

Without flags: disable png

With -colors flag: enable png

Chains

The following samples are equal

x := BgMagenta(Bold(Red("x")))
x := Red("x").Bold().BgMagenta()

The second is more readable

Colorize

There is Colorize function that allows to choose some colors and format from a side


func getColors() Color {
	// some stuff that returns appropriate colors and format
}

// [...]

func main() {
	fmt.Println(Colorize("Greeting", getColors()))
}

Less complicated example

x := Colorize("Greeting", GreenFg|GrayBg|BoldFm)

Unlike other color functions and methods (such as Red/BgBlue etc) a Colorize clears previous colors

x := Red("x").Colorize(BgGreen) // will be with green background only

Grayscale

fmt.Println("  ",
	Gray(1-1, " 00-23 ").BgGray(24-1),
	Gray(4-1, " 03-19 ").BgGray(20-1),
	Gray(8-1, " 07-15 ").BgGray(16-1),
	Gray(12-1, " 11-11 ").BgGray(12-1),
	Gray(16-1, " 15-07 ").BgGray(8-1),
	Gray(20-1, " 19-03 ").BgGray(4-1),
	Gray(24-1, " 23-00 ").BgGray(1-1),
)

grayscale png

8-bit colors

Methods Index and BgIndex implements 8-bit colors.

Index/BgIndex Meaning Foreground Background
0- 7 standard colors 30- 37 40- 47
8- 15 bright colors 90- 97 100-107
16-231 216 colors 38;5;n 48;5;n
232-255 24 grayscale 38;5;n 48;5;n

Supported colors & formats

  • formats
    • bold (1)
    • faint (2)
    • doubly-underline (21)
    • fraktur (20)
    • italic (3)
    • underline (4)
    • slow blink (5)
    • rapid blink (6)
    • reverse video (7)
    • conceal (8)
    • crossed out (9)
    • framed (51)
    • encircled (52)
    • overlined (53)
  • background and foreground colors, including bright
    • black
    • red
    • green
    • yellow (brown)
    • blue
    • magenta
    • cyan
    • white
    • 24 grayscale colors
    • 216 8-bit colors
All colors

linux png
white png

Standard and bright colors

linux black standard png linux white standard png

Formats are likely supported

formats supported gif

Formats are likely unsupported

formats rarely supported png

Limitations

There is no way to represent %T and %p with colors using a standard approach

package main

import (
	"fmt"

	. "github.com/logrusorgru/aurora"
)

func main() {
	r := Red("red")
	var i int
	fmt.Printf("%T %p\n", r, Green(&i))
}

Output will be without colors

aurora.value %!p(aurora.value={0xc42000a310 768 0})

The obvious workaround is Red(fmt.Sprintf("%T", some))

Windows

The Aurora provides ANSI colors only, so there is no support for Windows. That said, there are workarounds available. Check out these comments to learn more:

TTY

The Aurora has no internal TTY detectors by design. Take a look this comment if you want turn on colors for a terminal only, and turn them off for a file.

Licensing

Copyright © 2016-2020 The Aurora Authors. This work is free. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the the Unlicense. See the LICENSE file for more details.

Documentation

Overview

Package aurora implements ANSI-colors

Example (Printf)
fmt.Printf("%d %s", Blue(100), BgBlue("cats"))
Output:

�[34m100�[0m �[44mcats�[0m

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sprintf

func Sprintf(format interface{}, args ...interface{}) string

Sprintf allows to use Value as format. For example

v := Sprintf(Red("total: +3.5f points"), Blue(3.14))

In this case "total:" and "points" will be red, but 3.14 will be blue. But, in another example

v := Sprintf(Red("total: +3.5f points"), 3.14)

full string will be red. And no way to clear 3.14 to default format and color

Example
fmt.Print(
	Sprintf(
		Blue("we've got %d cats, but want %d"), // <- blue format
		Cyan(5),
		Bold(Magenta(25)),
	),
)
Output:

�[34mwe've got �[0;36m5�[0;34m cats, but want �[0;1;35m25�[0;34m�[0m

Types

type Aurora

type Aurora interface {

	// Reset wraps given argument returning Value
	// without formats and colors.
	Reset(arg interface{}) Value

	//
	// Formats
	//
	//
	// Bold or increased intensity (1).
	Bold(arg interface{}) Value
	// Faint, decreased intensity (2).
	Faint(arg interface{}) Value
	//
	// DoublyUnderline or Bold off, double-underline
	// per ECMA-48 (21).
	DoublyUnderline(arg interface{}) Value
	// Fraktur, rarely supported (20).
	Fraktur(arg interface{}) Value
	//
	// Italic, not widely supported, sometimes
	// treated as inverse (3).
	Italic(arg interface{}) Value
	// Underline (4).
	Underline(arg interface{}) Value
	//
	// SlowBlink, blinking less than 150
	// per minute (5).
	SlowBlink(arg interface{}) Value
	// RapidBlink, blinking 150+ per minute,
	// not widely supported (6).
	RapidBlink(arg interface{}) Value
	// Blink is alias for the SlowBlink.
	Blink(arg interface{}) Value
	//
	// Reverse video, swap foreground and
	// background colors (7).
	Reverse(arg interface{}) Value
	// Inverse is alias for the Reverse
	Inverse(arg interface{}) Value
	//
	// Conceal, hidden, not widely supported (8).
	Conceal(arg interface{}) Value
	// Hidden is alias for the Conceal
	Hidden(arg interface{}) Value
	//
	// CrossedOut, characters legible, but
	// marked for deletion (9).
	CrossedOut(arg interface{}) Value
	// StrikeThrough is alias for the CrossedOut.
	StrikeThrough(arg interface{}) Value
	//
	// Framed (51).
	Framed(arg interface{}) Value
	// Encircled (52).
	Encircled(arg interface{}) Value
	//
	// Overlined (53).
	Overlined(arg interface{}) Value

	//
	// Foreground colors
	//
	//
	// Black foreground color (30)
	Black(arg interface{}) Value
	// Red foreground color (31)
	Red(arg interface{}) Value
	// Green foreground color (32)
	Green(arg interface{}) Value
	// Yellow foreground color (33)
	Yellow(arg interface{}) Value
	// Brown foreground color (33)
	//
	// Deprecated: use Yellow instead, following specification
	Brown(arg interface{}) Value
	// Blue foreground color (34)
	Blue(arg interface{}) Value
	// Magenta foreground color (35)
	Magenta(arg interface{}) Value
	// Cyan foreground color (36)
	Cyan(arg interface{}) Value
	// White foreground color (37)
	White(arg interface{}) Value
	//
	// Bright foreground colors
	//
	// BrightBlack foreground color (90)
	BrightBlack(arg interface{}) Value
	// BrightRed foreground color (91)
	BrightRed(arg interface{}) Value
	// BrightGreen foreground color (92)
	BrightGreen(arg interface{}) Value
	// BrightYellow foreground color (93)
	BrightYellow(arg interface{}) Value
	// BrightBlue foreground color (94)
	BrightBlue(arg interface{}) Value
	// BrightMagenta foreground color (95)
	BrightMagenta(arg interface{}) Value
	// BrightCyan foreground color (96)
	BrightCyan(arg interface{}) Value
	// BrightWhite foreground color (97)
	BrightWhite(arg interface{}) Value
	//
	// Other
	//
	// Index of pre-defined 8-bit foreground color
	// from 0 to 255 (38;5;n).
	//
	//       0-  7:  standard colors (as in ESC [ 30–37 m)
	//       8- 15:  high intensity colors (as in ESC [ 90–97 m)
	//      16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
	//     232-255:  grayscale from black to white in 24 steps
	//
	Index(n uint8, arg interface{}) Value
	// Gray from 0 to 23.
	Gray(n uint8, arg interface{}) Value

	//
	// Background colors
	//
	//
	// BgBlack background color (40)
	BgBlack(arg interface{}) Value
	// BgRed background color (41)
	BgRed(arg interface{}) Value
	// BgGreen background color (42)
	BgGreen(arg interface{}) Value
	// BgYellow background color (43)
	BgYellow(arg interface{}) Value
	// BgBrown background color (43)
	//
	// Deprecated: use BgYellow instead, following specification
	BgBrown(arg interface{}) Value
	// BgBlue background color (44)
	BgBlue(arg interface{}) Value
	// BgMagenta background color (45)
	BgMagenta(arg interface{}) Value
	// BgCyan background color (46)
	BgCyan(arg interface{}) Value
	// BgWhite background color (47)
	BgWhite(arg interface{}) Value
	//
	// Bright background colors
	//
	// BgBrightBlack background color (100)
	BgBrightBlack(arg interface{}) Value
	// BgBrightRed background color (101)
	BgBrightRed(arg interface{}) Value
	// BgBrightGreen background color (102)
	BgBrightGreen(arg interface{}) Value
	// BgBrightYellow background color (103)
	BgBrightYellow(arg interface{}) Value
	// BgBrightBlue background color (104)
	BgBrightBlue(arg interface{}) Value
	// BgBrightMagenta background color (105)
	BgBrightMagenta(arg interface{}) Value
	// BgBrightCyan background color (106)
	BgBrightCyan(arg interface{}) Value
	// BgBrightWhite background color (107)
	BgBrightWhite(arg interface{}) Value
	//
	// Other
	//
	// BgIndex of 8-bit pre-defined background color
	// from 0 to 255 (48;5;n).
	//
	//       0-  7:  standard colors (as in ESC [ 40–47 m)
	//       8- 15:  high intensity colors (as in ESC [100–107 m)
	//      16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
	//     232-255:  grayscale from black to white in 24 steps
	//
	BgIndex(n uint8, arg interface{}) Value
	// BgGray from 0 to 23.
	BgGray(n uint8, arg interface{}) Value

	//
	// Special
	//
	// Colorize removes existing colors and
	// formats of the argument and applies given.
	Colorize(arg interface{}, color Color) Value

	//
	// Support methods
	//
	// Sprintf allows to use colored format.
	Sprintf(format interface{}, args ...interface{}) string
}

An Aurora implements colorizer interface. It also can be a non-colorizer

func NewAurora

func NewAurora(enableColors bool) Aurora

NewAurora returns a new Aurora interface that will support or not support colors depending the enableColors argument

Example (Colors)
a := NewAurora(true)
fmt.Println(a.Red("Red"))
Output:

�[31mRed�[0m
Example (No_colors)
a := NewAurora(false)
fmt.Println(a.Red("Not red"))
Output:

Not red

type Color

type Color uint

A Color type is a color. It can contain one background color, one foreground color and a format, including ideogram related formats.

const (
	BoldFm       Color = 1 << iota // 1
	FaintFm                        // 2
	ItalicFm                       // 3
	UnderlineFm                    // 4
	SlowBlinkFm                    // 5
	RapidBlinkFm                   // 6
	ReverseFm                      // 7
	ConcealFm                      // 8
	CrossedOutFm                   // 9

	FrakturFm         // 20
	DoublyUnderlineFm // 21 or bold off for some systems

	FramedFm    // 51
	EncircledFm // 52
	OverlinedFm // 53

	InverseFm       = ReverseFm    // alias to ReverseFm
	BlinkFm         = SlowBlinkFm  // alias to SlowBlinkFm
	HiddenFm        = ConcealFm    // alias to ConcealFm
	StrikeThroughFm = CrossedOutFm // alias to CrossedOutFm

)

Special formats

const (
	BlackFg   Color = (iota << shiftFg) | flagFg // 30, 90
	RedFg                                        // 31, 91
	GreenFg                                      // 32, 92
	YellowFg                                     // 33, 93
	BlueFg                                       // 34, 94
	MagentaFg                                    // 35, 95
	CyanFg                                       // 36, 96
	WhiteFg                                      // 37, 97

	BrightFg Color = ((1 << 3) << shiftFg) | flagFg // -> 90

	// BrownFg represents brown foreground color.
	//
	// Deprecated: use YellowFg instead, following specifications
	BrownFg = YellowFg
)

Foreground colors and related formats

const (
	BlackBg   Color = (iota << shiftBg) | flagBg // 40, 100
	RedBg                                        // 41, 101
	GreenBg                                      // 42, 102
	YellowBg                                     // 43, 103
	BlueBg                                       // 44, 104
	MagentaBg                                    // 45, 105
	CyanBg                                       // 46, 106
	WhiteBg                                      // 47, 107

	BrightBg Color = ((1 << 3) << shiftBg) | flagBg // -> 100

	// BrownBg represents brown foreground color.
	//
	// Deprecated: use YellowBg instead, following specifications
	BrownBg = YellowBg
)

Background colors and related formats

func (Color) IsValid deprecated

func (c Color) IsValid() bool

IsValid returns true always

Deprecated: don't use this method anymore

func (Color) Nos

func (c Color) Nos(zero bool) string

Nos returns string like 1;7;31;45. It may be an empty string for empty color. If the zero is true, then the string is prepended with 0;

type Value

type Value interface {
	// String returns string with colors. If there are any color
	// or format the string will be terminated with \033[0m
	fmt.Stringer
	// Format implements fmt.Formatter interface
	fmt.Formatter
	// Color returns value's color
	Color() Color
	// Value returns value's value (welcome to the tautology club)
	Value() interface{}

	// Bleach returns copy of original value without colors
	//
	// Deprecated: use Reset instead.
	Bleach() Value
	// Reset colors and formats
	Reset() Value

	//
	// Formats
	//
	//
	// Bold or increased intensity (1).
	Bold() Value
	// Faint, decreased intensity, reset the Bold (2).
	Faint() Value
	//
	// DoublyUnderline or Bold off, double-underline
	// per ECMA-48 (21). It depends.
	DoublyUnderline() Value
	// Fraktur, rarely supported (20).
	Fraktur() Value
	//
	// Italic, not widely supported, sometimes
	// treated as inverse (3).
	Italic() Value
	// Underline (4).
	Underline() Value
	//
	// SlowBlink, blinking less than 150
	// per minute (5).
	SlowBlink() Value
	// RapidBlink, blinking 150+ per minute,
	// not widely supported (6).
	RapidBlink() Value
	// Blink is alias for the SlowBlink.
	Blink() Value
	//
	// Reverse video, swap foreground and
	// background colors (7).
	Reverse() Value
	// Inverse is alias for the Reverse
	Inverse() Value
	//
	// Conceal, hidden, not widely supported (8).
	Conceal() Value
	// Hidden is alias for the Conceal
	Hidden() Value
	//
	// CrossedOut, characters legible, but
	// marked for deletion (9).
	CrossedOut() Value
	// StrikeThrough is alias for the CrossedOut.
	StrikeThrough() Value
	//
	// Framed (51).
	Framed() Value
	// Encircled (52).
	Encircled() Value
	//
	// Overlined (53).
	Overlined() Value

	//
	// Foreground colors
	//
	//
	// Black foreground color (30)
	Black() Value
	// Red foreground color (31)
	Red() Value
	// Green foreground color (32)
	Green() Value
	// Yellow foreground color (33)
	Yellow() Value
	// Brown foreground color (33)
	//
	// Deprecated: use Yellow instead, following specification
	Brown() Value
	// Blue foreground color (34)
	Blue() Value
	// Magenta foreground color (35)
	Magenta() Value
	// Cyan foreground color (36)
	Cyan() Value
	// White foreground color (37)
	White() Value
	//
	// Bright foreground colors
	//
	// BrightBlack foreground color (90)
	BrightBlack() Value
	// BrightRed foreground color (91)
	BrightRed() Value
	// BrightGreen foreground color (92)
	BrightGreen() Value
	// BrightYellow foreground color (93)
	BrightYellow() Value
	// BrightBlue foreground color (94)
	BrightBlue() Value
	// BrightMagenta foreground color (95)
	BrightMagenta() Value
	// BrightCyan foreground color (96)
	BrightCyan() Value
	// BrightWhite foreground color (97)
	BrightWhite() Value
	//
	// Other
	//
	// Index of pre-defined 8-bit foreground color
	// from 0 to 255 (38;5;n).
	//
	//       0-  7:  standard colors (as in ESC [ 30–37 m)
	//       8- 15:  high intensity colors (as in ESC [ 90–97 m)
	//      16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
	//     232-255:  grayscale from black to white in 24 steps
	//
	Index(n uint8) Value
	// Gray from 0 to 24.
	Gray(n uint8) Value

	//
	// Background colors
	//
	//
	// BgBlack background color (40)
	BgBlack() Value
	// BgRed background color (41)
	BgRed() Value
	// BgGreen background color (42)
	BgGreen() Value
	// BgYellow background color (43)
	BgYellow() Value
	// BgBrown background color (43)
	//
	// Deprecated: use BgYellow instead, following specification
	BgBrown() Value
	// BgBlue background color (44)
	BgBlue() Value
	// BgMagenta background color (45)
	BgMagenta() Value
	// BgCyan background color (46)
	BgCyan() Value
	// BgWhite background color (47)
	BgWhite() Value
	//
	// Bright background colors
	//
	// BgBrightBlack background color (100)
	BgBrightBlack() Value
	// BgBrightRed background color (101)
	BgBrightRed() Value
	// BgBrightGreen background color (102)
	BgBrightGreen() Value
	// BgBrightYellow background color (103)
	BgBrightYellow() Value
	// BgBrightBlue background color (104)
	BgBrightBlue() Value
	// BgBrightMagenta background color (105)
	BgBrightMagenta() Value
	// BgBrightCyan background color (106)
	BgBrightCyan() Value
	// BgBrightWhite background color (107)
	BgBrightWhite() Value
	//
	// Other
	//
	// BgIndex of 8-bit pre-defined background color
	// from 0 to 255 (48;5;n).
	//
	//       0-  7:  standard colors (as in ESC [ 40–47 m)
	//       8- 15:  high intensity colors (as in ESC [100–107 m)
	//      16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
	//     232-255:  grayscale from black to white in 24 steps
	//
	BgIndex(n uint8) Value
	// BgGray from 0 to 24.
	BgGray(n uint8) Value

	//
	// Special
	//
	// Colorize removes existing colors and
	// formats of the argument and applies given.
	Colorize(color Color) Value
	// contains filtered or unexported methods
}

A Value represents any printable value with it's color

func BgBlack

func BgBlack(arg interface{}) Value

BgBlack background color (40)

func BgBlue

func BgBlue(arg interface{}) Value

BgBlue background color (44)

func BgBrightBlack

func BgBrightBlack(arg interface{}) Value

BgBrightBlack background color (100)

func BgBrightBlue

func BgBrightBlue(arg interface{}) Value

BgBrightBlue background color (104)

func BgBrightCyan

func BgBrightCyan(arg interface{}) Value

BgBrightCyan background color (106)

func BgBrightGreen

func BgBrightGreen(arg interface{}) Value

BgBrightGreen background color (102)

func BgBrightMagenta

func BgBrightMagenta(arg interface{}) Value

BgBrightMagenta background color (105)

func BgBrightRed

func BgBrightRed(arg interface{}) Value

BgBrightRed background color (101)

func BgBrightWhite

func BgBrightWhite(arg interface{}) Value

BgBrightWhite background color (107)

func BgBrightYellow

func BgBrightYellow(arg interface{}) Value

BgBrightYellow background color (103)

func BgBrown deprecated

func BgBrown(arg interface{}) Value

BgBrown background color (43)

Deprecated: use BgYellow instead, following specification

func BgCyan

func BgCyan(arg interface{}) Value

BgCyan background color (46)

func BgGray

func BgGray(n uint8, arg interface{}) Value

BgGray from 0 to 24.

func BgGreen

func BgGreen(arg interface{}) Value

BgGreen background color (42)

func BgIndex

func BgIndex(n uint8, arg interface{}) Value

BgIndex of 8-bit pre-defined background color from 0 to 255 (48;5;n).

  0-  7:  standard colors (as in ESC [ 40–47 m)
  8- 15:  high intensity colors (as in ESC [100–107 m)
 16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
232-255:  grayscale from black to white in 24 steps

func BgMagenta

func BgMagenta(arg interface{}) Value

BgMagenta background color (45)

func BgRed

func BgRed(arg interface{}) Value

BgRed background color (41)

func BgWhite

func BgWhite(arg interface{}) Value

BgWhite background color (47)

func BgYellow

func BgYellow(arg interface{}) Value

BgYellow background color (43)

func Black

func Black(arg interface{}) Value

Black foreground color (30)

func Blink(arg interface{}) Value

Blink is alias for the SlowBlink.

func Blue

func Blue(arg interface{}) Value

Blue foreground color (34)

func Bold

func Bold(arg interface{}) Value

Bold or increased intensity (1).

Example
fmt.Println("value:", Bold(Green(99)))
Output:

value: �[1;32m99�[0m

func BrightBlack

func BrightBlack(arg interface{}) Value

BrightBlack foreground color (90)

func BrightBlue

func BrightBlue(arg interface{}) Value

BrightBlue foreground color (94)

func BrightCyan

func BrightCyan(arg interface{}) Value

BrightCyan foreground color (96)

func BrightGreen

func BrightGreen(arg interface{}) Value

BrightGreen foreground color (92)

func BrightMagenta

func BrightMagenta(arg interface{}) Value

BrightMagenta foreground color (95)

func BrightRed

func BrightRed(arg interface{}) Value

BrightRed foreground color (91)

func BrightWhite

func BrightWhite(arg interface{}) Value

BrightWhite foreground color (97)

func BrightYellow

func BrightYellow(arg interface{}) Value

BrightYellow foreground color (93)

func Brown deprecated

func Brown(arg interface{}) Value

Brown foreground color (33)

Deprecated: use Yellow instead, following specification

func Colorize

func Colorize(arg interface{}, color Color) Value

Colorize wraps given value into Value with given colors. For example

s := Colorize("some", BlueFg|GreenBg|BoldFm)

returns a Value with blue foreground, green background and bold. Unlike functions like Red/BgBlue/Bold etc. This function clears all previous colors and formats. Thus

s := Colorize(Red("some"), BgBlue)

clears red color from value

func Conceal

func Conceal(arg interface{}) Value

Conceal hides text, preserving an ability to select the text and copy it. It is not widely supported (8).

func CrossedOut

func CrossedOut(arg interface{}) Value

CrossedOut makes characters legible, but marked for deletion (9).

func Cyan

func Cyan(arg interface{}) Value

Cyan foreground color (36)

func DoublyUnderline

func DoublyUnderline(arg interface{}) Value

DoublyUnderline or Bold off, double-underline per ECMA-48 (21).

func Encircled

func Encircled(arg interface{}) Value

Encircled (52).

func Faint

func Faint(arg interface{}) Value

Faint decreases intensity (2). The Faint rejects the Bold.

func Fraktur

func Fraktur(arg interface{}) Value

Fraktur is rarely supported (20).

func Framed

func Framed(arg interface{}) Value

Framed (51).

func Gray

func Gray(n uint8, arg interface{}) Value

Gray from 0 to 24.

func Green

func Green(arg interface{}) Value

Green foreground color (32)

func Hidden

func Hidden(arg interface{}) Value

Hidden is alias for the Conceal

func Index

func Index(n uint8, arg interface{}) Value

Index of pre-defined 8-bit foreground color from 0 to 255 (38;5;n).

  0-  7:  standard colors (as in ESC [ 30–37 m)
  8- 15:  high intensity colors (as in ESC [ 90–97 m)
 16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
232-255:  grayscale from black to white in 24 steps

func Inverse

func Inverse(arg interface{}) Value

Inverse is alias for the Reverse

func Italic

func Italic(arg interface{}) Value

Italic is not widely supported, sometimes treated as inverse (3).

func Magenta

func Magenta(arg interface{}) Value

Magenta foreground color (35)

func Overlined

func Overlined(arg interface{}) Value

Overlined (53).

func RapidBlink(arg interface{}) Value

RapidBlink makes text blink 150+ per minute. It is not widely supported (6).

func Red

func Red(arg interface{}) Value

Red foreground color (31)

Example
fmt.Println("value exceeds min-threshold:", Red(3.14))
Output:

value exceeds min-threshold: �[31m3.14�[0m

func Reset

func Reset(arg interface{}) Value

Reset wraps given argument returning Value without formats and colors.

func Reverse

func Reverse(arg interface{}) Value

Reverse video, swap foreground and background colors (7).

func SlowBlink(arg interface{}) Value

SlowBlink makes text blink less than 150 per minute (5).

func StrikeThrough

func StrikeThrough(arg interface{}) Value

StrikeThrough is alias for the CrossedOut.

func Underline

func Underline(arg interface{}) Value

Underline (4).

func White

func White(arg interface{}) Value

White foreground color (37)

func Yellow

func Yellow(arg interface{}) Value

Yellow foreground color (33)

Jump to

Keyboard shortcuts

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