co

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 5 Imported by: 0

README

co

The library for terminal output formatting with ANSI colors

Install

$ go get -u github.com/Binbiubiubiu/co

Example

package main

import (
	. "github.com/Binbiubiubiu/co"
)

func main() {
	println(GreenBright("Hello"), BgCyanBright(RedBright("Binbiubiubiu")))
}

Bench

$ go test -bench=.  
goos: darwin
goarch: amd64
pkg: github.com/Binbiubiubiu/co
cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Benchmark_co-8                   2007859               594.8 ns/op
Benchmark_fatih_color-8           504742              2027 ns/op
Benchmark_gookit_color-8         1488526               801.0 ns/op
PASS
ok      github.com/Binbiubiubiu/co      6.489s

Thanks

colorette 🌈Easily set your terminal text color & styles.

Documentation

Index

Constants

View Source
const IS_WINDOWS = runtime.GOOS == "windows"

Variables

View Source
var BgBlack = colors.BgBlack
View Source
var BgBlackBright = colors.BgBlackBright
View Source
var BgBlue = colors.BgBlue
View Source
var BgBlueBright = colors.BgBlueBright
View Source
var BgCyan = colors.BgCyan
View Source
var BgCyanBright = colors.BgCyanBright
View Source
var BgGreen = colors.BgGreen
View Source
var BgGreenBright = colors.BgGreenBright
View Source
var BgMagenta = colors.BgMagenta
View Source
var BgMagentaBright = colors.BgMagentaBright
View Source
var BgRed = colors.BgRed
View Source
var BgRedBright = colors.BgRedBright
View Source
var BgWhite = colors.BgWhite
View Source
var BgWhiteBright = colors.BgWhiteBright
View Source
var BgYellow = colors.BgYellow
View Source
var BgYellowBright = colors.BgYellowBright
View Source
var Black = colors.Black
View Source
var BlackBright = colors.BlackBright
View Source
var Blue = colors.Blue
View Source
var BlueBright = colors.BlueBright
View Source
var Bold = colors.Bold
View Source
var Cyan = colors.Cyan
View Source
var CyanBright = colors.CyanBright
View Source
var Dim = colors.Dim
View Source
var Gray = colors.Gray
View Source
var Green = colors.Green
View Source
var GreenBright = colors.GreenBright
View Source
var Hidden = colors.Hidden
View Source
var Inverse = colors.Inverse
View Source
var (
	IsColorSupported = !isDisabled &&
		(isForced || (IS_WINDOWS && !isDumbTerminal) || isCompatibleTerminal || isCI)
)
View Source
var Italic = colors.Italic
View Source
var Magenta = colors.Magenta
View Source
var MagentaBright = colors.MagentaBright
View Source
var Red = colors.Red
View Source
var RedBright = colors.RedBright
View Source
var Reset = colors.Reset
View Source
var Strikethrough = colors.Strikethrough
View Source
var Underline = colors.Underline
View Source
var White = colors.White
View Source
var WhiteBright = colors.WhiteBright
View Source
var Yellow = colors.Yellow
View Source
var YellowBright = colors.YellowBright

Functions

This section is empty.

Types

type ColorFunc

type ColorFunc func(string) string

Color formatting functions

type Colors

type Colors struct {
	Reset           ColorFunc
	Bold            ColorFunc
	Dim             ColorFunc
	Italic          ColorFunc
	Underline       ColorFunc
	Inverse         ColorFunc
	Hidden          ColorFunc
	Strikethrough   ColorFunc
	Black           ColorFunc
	Red             ColorFunc
	Green           ColorFunc
	Yellow          ColorFunc
	Blue            ColorFunc
	Magenta         ColorFunc
	Cyan            ColorFunc
	White           ColorFunc
	Gray            ColorFunc
	BgBlack         ColorFunc
	BgRed           ColorFunc
	BgGreen         ColorFunc
	BgYellow        ColorFunc
	BgBlue          ColorFunc
	BgMagenta       ColorFunc
	BgCyan          ColorFunc
	BgWhite         ColorFunc
	BlackBright     ColorFunc
	RedBright       ColorFunc
	GreenBright     ColorFunc
	YellowBright    ColorFunc
	BlueBright      ColorFunc
	MagentaBright   ColorFunc
	CyanBright      ColorFunc
	WhiteBright     ColorFunc
	BgBlackBright   ColorFunc
	BgRedBright     ColorFunc
	BgGreenBright   ColorFunc
	BgYellowBright  ColorFunc
	BgBlueBright    ColorFunc
	BgMagentaBright ColorFunc
	BgCyanBright    ColorFunc
	BgWhiteBright   ColorFunc
}

func CreateColors

func CreateColors() Colors

Create a color tool function

func UseColors

func UseColors(useColor bool) Colors

Create a color utility function with a useColor property

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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