colors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetEnabler

func SetEnabler(e Enabler)

SetEnabler 设置颜色输出控制器

func ToBlue

func ToBlue(str string) string

ToBlue 将字符串转成蓝色

func ToGray

func ToGray(str string) string

ToGray 将字符串转成灰色

func ToGreen

func ToGreen(str string) string

ToGreen 将字符串转成绿色

func ToPurple

func ToPurple(str string) string

ToPurple 将字符串转成紫色

func ToRed

func ToRed(str string) string

ToRed 将字符串转成红色

func ToYellow

func ToYellow(str string) string

ToYellow 将字符串转成黄色

func WrapColor

func WrapColor(color C, str string) string

WrapColor 将字符串 str 包裹上指定颜色的 ANSI 字符

如果用户关闭了颜色输出, 则直接返回原字符串

Types

type C

type C string
const (
	Blue   C = "\x1b[38;2;090;156;248m"
	Green  C = "\x1b[38;2;126;192;080m"
	Yellow C = "\x1b[38;2;220;165;080m"
	Red    C = "\x1b[38;2;228;116;112m"
	Purple C = "\x1b[38;2;160;186;250m"
	Gray   C = "\x1b[38;2;145;147;152m"
)

日志颜色输出常量

type Enabler

type Enabler interface {

	// EnableColor 标记是否启用颜色输出
	EnableColor() bool
}

Enabler

Jump to

Keyboard shortcuts

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