1 Star 0 Fork 1

技术狼/go-fun

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
color.go 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
技术狼 提交于 12个月前 . color
package fun
import (
"fmt"
)
// 前景 背景 颜色
// ---------------------------------------
// 30 40 黑色
// 31 41 红色
// 32 42 绿色
// 33 43 黄色
// 34 44 蓝色
// 35 45 紫红色
// 36 46 青蓝色
// 37 47 白色
//
// 代码 意义
// -------------------------
// 0 终端默认设置
// 1 高亮显示
// 4 使用下划线
// 5 闪烁
// 7 反白显示
// 8 不可见
const (
COLOR_BLACK = iota + 30
COLOR_RED
COLOR_GREEN
COLOR_YELLOW
COLOR_BLUE
COLOR_MAGENTA
COLOR_CYAN
COLOR_WHITE
)
// 黑色
func ColorBlack(msg string) string {
return Color(msg, 0, 0, COLOR_BLACK)
}
// 红色
func ColorRed(msg string) string {
return Color(msg, 0, 0, COLOR_RED)
}
// 绿色
func ColorGreen(msg string) string {
return Color(msg, 0, 0, COLOR_GREEN)
}
// 黄色
func ColorYellow(msg string) string {
return Color(msg, 0, 0, COLOR_YELLOW)
}
// 蓝色
func ColorBlue(msg string) string {
return Color(msg, 0, 0, COLOR_BLUE)
}
// 洋红色
func ColorMagenta(msg string) string {
return Color(msg, 0, 0, COLOR_MAGENTA)
}
// 青色
func ColorCyan(msg string) string {
return Color(msg, 0, 0, COLOR_CYAN)
}
// 白色
func ColorWhite(msg string) string {
return Color(msg, 0, 0, COLOR_WHITE)
}
// 获取文本颜色
func Color(msg string, conf, bg, text int) string {
return fmt.Sprintf("%c[%d;%d;%dm%s%c[0m", 0x1B, conf, bg, text, msg, 0x1B)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jishulangcom/go-fun.git
git@gitee.com:jishulangcom/go-fun.git
jishulangcom
go-fun
go-fun
v0.0.4

搜索帮助