Skip to content

ErfanMomeniii/colorful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image description

go version license version

colorful

colorful is a lightweight package for rendering colorful text in terminal with Go . You can use this instead of fmt package for having many features. For seeing usages check this.

Documentation

Install

go get github.com/erfanmomeniii/colorful/v2

Next, include it in your application:

import "github.com/erfanmomeniii/colorful/v2"

Quick Start

The following example demonstrates how to print text in desired format and color:

package main

import (
	"github.com/erfanmomeniii/colorful/v2"
)

func main() {
	colorful.WithColor(colorful.RedColor).
		WithBackgroundColor(colorful.BlueBackgroundColor).
		Println("RedColorBlueBackground")

	colorful.WithColor(colorful.GreenColor).
		Println("GreenColor")

	colorful.WithBackgroundColor(colorful.YellowBackgroundColor).
		Println("YellowBackground")
}

You can also print many texts with different colors and background colors only in one operation like below:

package main

import (
	"github.com/erfanmomeniii/colorful/v2"
)

func main() {
	colorful.WithColor(colorful.RedColor).
		Print("Hi ").
		WithColor(colorful.BlueColor).
		Print("Erfan")
}

output:

Supported Colors

red color
green color
yellow color
blue color
magenta color
cyan color
white color
black color
brightBlack color
brightRed color
brightGreen color
brightYellow color
brightBlue color
brightMagenta color
brightCyan color
brightWhite color

You can use the following color codes :

color code

Supported Background Colors

black background
red background
green background
yellow background
blue background
magenta background
cyan background
white background
brightBlack background
brightRed background
brightGreen background
brightYellow background
brightBlue background
brightMagenta background
brightCyan background
brightWhite background

You can use the following background codes :

color code

Contributing

Pull requests are welcome. For changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.