代码拉取完成,页面将自动刷新
// 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])
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。