| 12345678910111213141516171819202122232425262728293031323334353637383940 | package consoleimport (	"fmt"	"github.com/mgutz/ansi"	"os")// Success 打印一条成功消息,绿色输出func Success(msg string) {	colorOut(msg, "green")}// Error 打印一条报错消息,红色输出func Error(msg string) {	colorOut(msg, "red")}// Warning 打印一条提示消息,黄色输出func Warning(msg string) {	colorOut(msg, "yellow")}// Exit 打印一条报错消息,并退出 os.Exit(1)func Exit(msg string) {	Error(msg)	os.Exit(1)}// ExitIf 语法糖,自带 err != nil 判断func ExitIf(err error) {	if err != nil {		Exit(err.Error())	}}// colorOut 内部使用,设置高亮颜色func colorOut(message, color string) {	_, _ = fmt.Fprintln(os.Stdout, ansi.Color(message, color))}
 |