后端程序员之路 58、go wlog
daviddengcn/go-colortext: Change the color of console text.
https://github.com/daviddengcn/go-colortext
dixonwille/wlog: A simple logging interface that supports cross-platform color and concurrency.
https://github.com/dixonwille/wlog
package main import (
"strings"
"os"
. "github.com/dixonwille/wlog"
) func TestWLog() {
var ui UI
reader := strings.NewReader("User Input\r\n") //Simulate user typing "User Input" then pressing [enter] when reading from os.Stdin
ui = New(reader, os.Stdout, os.Stdout)
ui = AddConcurrent(ui) var addPrefixCases = []struct {
ask string
err string
inf string
log string
out string
suc string
run string
war string
}{
{" ", " ", " ", " ", " ", " ", " ", " "},
{" ", " ", " ", " ", " ", " ", " ", " "},
{Cross, Check, "!", "~", "@", "#", "+", "="},
{"%", "^", "&", "*", "@", ":", ",", "?"},
}
for _, c := range addPrefixCases {
prefix := AddPrefix(c.ask, c.err, c.inf, c.log, c.out, c.run, c.suc, c.war, ui)
prefix.Ask("Ask question", "")
prefix.Error("Error message")
prefix.Info("Info message")
prefix.Output("Output message")
prefix.Running("Running message")
prefix.Success("Success message")
prefix.Warn("Warning message")
} var addColorCases = []struct {
logColor Color
outputColor Color
successColor Color
infoColor Color
errorColor Color
warnColor Color
runningColor Color
askColor Color
responseColor Color
}{
{None, Blue, Green, Red, Yellow, Cyan, Magenta, White, Black},
{BrightBlue, BrightGreen, BrightRed, BrightYellow, BrightCyan, BrightMagenta, BrightWhite, BrightBlack, None},
}
for _, c := range addColorCases {
color := AddColor(c.askColor, c.errorColor, c.infoColor, c.logColor, c.outputColor, c.responseColor, c.runningColor, c.successColor, c.warnColor, ui)
color.Ask("Ask question", "")
color.Error("Error message")
color.Info("Info message")
color.Output("Output message")
color.Running("Running message")
color.Success("Success message")
color.Warn("Warning message")
}
}
后端程序员之路 58、go wlog的更多相关文章
- 后端程序员之路 59、go uiprogress
gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...
- 后端程序员之路 43、Redis list
Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...
- 后端程序员之路 22、RESTful API
理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...
- 后端程序员之路 16、信息熵 、决策树、ID3
信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...
- 后端程序员之路 7、Zookeeper
Zookeeper是hadoop的一个子项目,提供分布式应用程序协调服务. Apache ZooKeeper - Homehttps://zookeeper.apache.org/ zookeeper ...
- 后端程序员之路 4、一种monitor的做法
record_t包含_sum._count._time_stamp._max._min最基础的一条记录,可以用来记录最大值.最小值.计数.总和metric_t含有RECORD_NUM(6)份recor ...
- 后端程序员之路 57、go json
go自带json处理库,位于encoding/json,里面的test很具参考意义,特别是example_test.go json - The Go Programming Languagehttps ...
- 后端程序员之路 56、go package
package分包.import导入包import . "package1" 省略前缀包名import p1 "package1" 起别名import _ & ...
- 后端程序员之路 55、go redis
redigo有点像hiredis,只提供了最基本的连接和执行命令接口. 找到个不错的redis库: https://github.com/go-redis/redis func ExampleNewC ...
随机推荐
- HDU6061 RXD and functions【NTT】
\(RXD\ and\ functions\) Problem Description RXD has a polynomial function \(f(x)\), \(f(x)=\sum ^{n} ...
- k倍区间(解题报告)前缀和简单应用
测评地址 问题 1882: [蓝桥杯][2017年第八届真题]k倍区间 时间限制: 1Sec 内存限制: 128MB 提交: 351 解决: 78 题目描述 给定一个长度为N的数列,A1, A2, . ...
- zjnuSAVEZ (字符串hash)
Description There are eight planets and one planetoid in the Solar system. It is not a well known fa ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) B. Repainting Street (枚举)
题意:有\(n\)栋房子,每栋房子都有自己的颜色\(c_i\),你每次可以对连续的长度为\(k\)的区间改变任何房子的颜色,问最少多少次可以使得所有房子颜色相同. 题解:因为只有\(100\)中颜色, ...
- Codeforces Round #602 Div2 D1. Optimal Subsequences (Easy Version)
题意:给你一个数组a,询问m次,每次返回长度为k的和最大的子序列(要求字典序最小)的pos位置上的数字. 题解:和最大的子序列很简单,排个序就行,但是题目要求字典序最小,那我们在刚开始的时候先记录每个 ...
- 表达式目录树插件xLiAd.SqlEx.Core
表达式目录树使用时 引用xLiAd.SqlEx.Core ,是一个很好的插件 using xLiAd.SqlEx.Core.Helper; Expression<Func<Reported ...
- 微服务架构学习Day01-SpringBoot入门
基本概念 SpringBoot的优点: 可以创建独立的Spring应用 SpringBoot嵌入Tomcat,Jetty和Unsertow, 不需要部署war文件 根据需要通过maven获取start ...
- C++ new delete malloc free
title: C++ new delete malloc free date: 2020-03-10 categories: c++ tags: 语法 C++的new delete malloc fr ...
- 内网域渗透之MS14-068复现(CVE-2014-6324)
在做域渗透测试时,当我们拿到了一个普通域成员的账号后,想继续对该域进行渗透,拿到域控服务器权限.如果域控服务器存在MS14_068漏洞,并且未打补丁,那么我们就可以利用MS14_068快速获得域控服务 ...
- Eclipce怎么恢复误删类
选择误删除文件在eclipse所在包(文件夹) 在包上单击右键. 选择restore from local history... 在弹出的对话框中选择需要恢复的文件