百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

color

> 编程语言
开源

Go (golang) 的颜色包

8.0K stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Go (golang) 的颜色包

颜色 [https://github.com/fatih/color/actions] [ (ZZURL1Z)

颜色允许您使用颜色化的输出 。 代码 (http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). 这个 也有对 Windows 的支持 ! API可以用几种方式,选择一个 适合你们

□ 安装

(原始内容存档于2019-09-29) (英语). ``` go get github.com/fatih/color


□ 实例

标准颜色

ZZ1ZZ

QQ RGB 颜色

如果终端支持24位颜色,可以使用RGB颜色代码.

(原始内容存档于2019-09-29). ```go
color.RGB(255, 128, 0).Println("foreground orange")
color.RGB(230, 42, 42).Println("foreground red")

color.BgRGB(255, 128, 0).Println("background orange")
color.BgRGB(230, 42, 42).Println("background red")

混合和再利用颜色

ZZCODE3 乐团

使用自己的输出( io. Writer)

(原始内容存档于2019-09-26). ```go // Use your own io.Writer output color.New(color.FgBlue).Fprintln(myWriter, "blue color!")

blue := color.New(color.FgBlue) blue.Fprint(writer, "This will print text in blue.")


自定义打印函数( PrintFunc)

ZZCODE5 乐团

QQ 自定义快取功能( FprintFunc)

ZZCODE6 乐团

插入到非颜色字符串( SprintFunc)

ZZ7ZZ

• 插入现有代码

开始
// 使用方便的标准颜色
颜色. Set( 颜色. FgYellow)

fmt.Println ("现有文本现在为黄色").
fmt.printf ("这个%s\n","太")

颜色 撤销( ) // 不要忘记未定

/ 您可以混合参数
颜色. Set (color.). Fg Magenta, 颜色. 粗体)

Issues· 34 开放

查看全部 Issues在 GitHub 打开
  • #271

    功能请求: .RemoveColor() 函数

    更新于 2026年3月1日
  • #176

    [错误] 在 Powershell 中,黄色颜色不起作用

    更新于 2025年12月15日
  • #263

    在 vscode 中使用 F5 键开始调试时,输出没有颜色。使用以下代码输出,就不会有问题了!

    更新于 2025年8月18日
  • #257

    在 VSCode 测试结果输出中错误地禁用了颜色

    更新于 2025年4月14日
  • #253

    支持超链接转义字符

    更新于 2025年3月27日
  • #240

    库与 text/tabwriter 不兼容

    更新于 2025年2月10日
  • #229

    Docker 容器控制台支持

    更新于 2024年12月25日
  • #241

    打印字符串以新行符 '\n' 结束

    更新于 2024年10月3日
  • #230

    设置/取消设置 Writer 不对称性

    更新于 2024年10月3日
  • #239

    通过 SSH 连接时 CrossedOut 不能正常工作

    更新于 2024年9月16日

> 标签

Goansicolorcoloringgo

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年10月1日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言