color

package module
v0.0.0-...-d832cf5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 1 Imported by: 2

README

color

Build Status | codecov | Go Report Card | GoDoc

A color formatter that allows you to add color on your output. The easy way to use the color:

import log github.com/joaosoft/color

fmt.Fprintf(os.Stdout, fmt.Sprintf("%s joao", color.WithColor("hello", color.FormatBold, color.ForegroundRed, color.BackgroundCyan)))
If i miss something or you have something interesting, please be part of this project. Let me know! My contact is at the end.

With support for

  • text format
  • foreground color
  • background color
Go
go get github.com/joaosoft/color

Usage

This examples are available in the project at color/examples

func main() {
	fmt.Fprintf(os.Stdout, fmt.Sprintf("%s joao", color.WithColor("hello", color.FormatBold, color.ForegroundRed, color.BackgroundCyan)))
}

Known issues

Follow me at

Facebook: https://www.facebook.com/joaosoft

LinkedIn: https://www.linkedin.com/in/joaosoft

If you have something to add, please let me know joaosoft@gmail.com

Documentation

Index

Constants

View Source
const (
	NormalIntensityForeground = 30
	HighIntensityForeground   = 90
	NormalIntensityBackground = 40
	HighIntensityBackground   = 100
)
View Source
const Escape = "\033"

Variables

This section is empty.

Functions

func WithColor

func WithColor(text string, format Format, foreground Foreground, background Background, params ...interface{}) string

Types

type Background

type Background int
const (
	// background text colors
	BackgroundBlack Background = iota + NormalIntensityBackground
	BackgroundRed
	BackgroundGreen
	BackgroundYellow
	BackgroundBlue
	BackgroundMagenta
	BackgroundCyan
	BackgroundWhite
)
const (
	// background hi-intensity text colors
	BackgroundHiBlack Background = iota + HighIntensityBackground
	BackgroundHiRed
	BackgroundHiGreen
	BackgroundHiYellow
	BackgroundHiBlue
	BackgroundHiMagenta
	BackgroundHiCyan
	BackgroundHiWhite
)

type Foreground

type Foreground int
const (
	// foreground text colors
	ForegroundBlack Foreground = iota + NormalIntensityForeground
	ForegroundRed
	ForegroundGreen
	ForegroundYellow
	ForegroundBlue
	ForegroundMagenta
	ForegroundCyan
	ForegroundWhite
)
const (
	// foreground hi-intensity text colors
	ForegroundHiBlack Foreground = iota + HighIntensityForeground
	ForegroundHiRed
	ForegroundHiGreen
	ForegroundHiYellow
	ForegroundHiBlue
	ForegroundHiMagenta
	ForegroundHiCyan
	ForegroundHiWhite
)

type Format

type Format int
const (
	// format
	FormatReset Format = iota
	FormatBold
	FormatFaint
	FormatItalic
	FormatUnderline
	FormatBlinkSlow
	FormatBlinkRapid
	FormatReverseVideo
	FormatConcealed
	FormatCrossedOut
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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