Skip to content

ermanimer/go-color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-color

go-color is a simple color library for Go that allows you to print colored text for the Unix terminal.

Installation

go install github.com/ermanimer/go-color@latest

Usage

// use predefined colors
color.Red.Println("red text")

// create colors with color codes, see the color chart below.
color.New(240).Println("gray text")

// add background color
color.New(220).With(color.Blue).Println("orange text on a blue background")

// create colored strings
fmt.Printf("%s %s\n", color.Green.Paint("green text"), color.Yellow.Paint("with yellow text"))

Output

output

Color Codes:

color_codes

Contribution

Your contribution and feedback are always welcome.

References

ANSI Escape Code