显示颜色的包:github.com/fatih/color

常用包 Liemer_Lius 247℃

参考:https://blog.csdn.net/inthat/article/details/123570590

package main

import "github.com/fatih/color"

func main() {
	// Create a new color object
	c := color.New(color.FgCyan).Add(color.Underline)
	c.Println("Prints cyan text with an underline.")

	// Or just add them to New()
	d := color.New(color.FgCyan, color.Bold)
	d.Printf("This prints bold cyan %s\n", "too!.")

	// Mix up foreground and background colors, create new mixes!
	red := color.New(color.FgRed)

	boldRed := red.Add(color.Bold)
	boldRed.Println("This will print text in bold red.")

	whiteBackground := red.Add(color.BgWhite)
	whiteBackground.Println("Red text with white background.")

}

在这里插入图片描述

 

 

 

 

转载请注明:liutianfeng.com » 显示颜色的包:github.com/fatih/color

喜欢 (0)

评论已关闭。