Vishal Rana a1a2f7c066 Color now has New function 10 سال پیش
..
README.md a1a2f7c066 Color now has New function 10 سال پیش
color.go a1a2f7c066 Color now has New function 10 سال پیش
color_test.go a1a2f7c066 Color now has New function 10 سال پیش

README.md

Color

Style terminal text.

Installation

go get github.com/labstack/gommon/color

Windows?

Try cmder or https://github.com/mattn/go-colorable

Usage

import github.com/labstack/gommon/color

Colored text

fmt.Println(color.Black("black"))
fmt.Println(color.Red("red"))
fmt.Println(color.Green("green"))
fmt.Println(color.Yellow("yellow"))
fmt.Println(color.Blue("blue"))
fmt.Println(color.Magenta("magenta"))
fmt.Println(color.Cyan("cyan"))
fmt.Println(color.White("white"))
fmt.Println(color.Grey("grey"))

Colored Text

Colored background

fmt.Println(color.BlackBg("black background", color.Wht))
fmt.Println(color.RedBg("red background"))
fmt.Println(color.GreenBg("green background"))
fmt.Println(color.YellowBg("yellow background"))
fmt.Println(color.BlueBg("blue background"))
fmt.Println(color.MagentaBg("magenta background"))
fmt.Println(color.CyanBg("cyan background"))
fmt.Println(color.WhiteBg("white background"))

Colored Background

Emphasis

fmt.Println(color.Bold("bold"))
fmt.Println(color.Dim("dim"))
fmt.Println(color.Italic("italic"))
fmt.Println(color.Underline("underline"))
fmt.Println(color.Inverse("inverse"))
fmt.Println(color.Hidden("hidden"))
fmt.Println(color.Strikeout("strikeout"))

Emphasis

Mix and match

fmt.Println(color.Green("bold green with white background", color.B, color.WhtBg))
fmt.Println(color.Red("underline red", color.U))
fmt.Println(color.Yellow("dim yellow", color.Dm))
fmt.Println(color.Cyan("inverse cyan", color.In))
fmt.Println(color.Blue("bold underline dim blue", color.B, color.U, color.Dm))

Mix and match

New instance

c := New()
c.Green("green")