1 Star 2 Fork 3

kristas/booting-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
color.go 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
kristas 提交于 2021-04-16 18:55 . feat: add casbin
// Copyright (c) 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/**
*@describe:
*@author wfl19/Kristas
*@date 2021/04/14
*/
package console
import "fmt"
const (
Reset = iota
Red //红
RedBold //红粗
Green //绿
GreenBold //绿粗
Yellow //黄
YellowBold //黄粗
Blue //蓝
BlueBold //蓝粗
Magenta //紫
MagentaBold //紫粗
Cyan //深绿
CyanBold //深绿粗
White //白
WhiteBold //白粗
)
var colorMap = map[int]string{
Reset: "\033[0m",
Red: "\033[31m", //红
RedBold: "\033[31;1m", //红粗
Green: "\033[32m", //绿
GreenBold: "\033[32;1m", //绿粗
Yellow: "\033[33m", //黄
YellowBold: "\033[33;1m", //黄粗
Blue: "\033[34m", //蓝
BlueBold: "\033[34;1m", //蓝粗
Magenta: "\033[35m", //紫
MagentaBold: "\033[35;1m", //紫粗
Cyan: "\033[36m", //深绿
CyanBold: "\033[36;1m", //深绿粗
White: "\033[37m", //白
WhiteBold: "\033[37;1m", //白粗
}
func Draw(color int, s string) string {
return fmt.Sprintf("%s%s%s", colorMap[color], s, colorMap[Reset])
}
func Drawf(color int, s string, args ...interface{}) string {
s = fmt.Sprintf(s, args...)
return fmt.Sprintf("%s%s%s", colorMap[color], s, colorMap[Reset])
}
func Drawln(color int, s string) string {
return fmt.Sprintf("%s%s%s\n", colorMap[color], s, colorMap[Reset])
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kristas/booting-go.git
git@gitee.com:kristas/booting-go.git
kristas
booting-go
booting-go
v1.2.3

搜索帮助