Documentation ¶ Index ¶ func SetEnabler(e Enabler) func ToBlue(str string) string func ToGray(str string) string func ToGreen(str string) string func ToPurple(str string) string func ToRed(str string) string func ToYellow(str string) string func WrapColor(color C, str string) string type C type Enabler 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 Source Files ¶ View all Source files colors.go Click to show internal directories. Click to hide internal directories.