import (

func TestColor(tt *testing.T) {
    // Create SprintXxx functions to mix strings with other non-colorized strings:
    yellow := color.New(color.FgYellow).SprintFunc()
    red := color.New(color.FgRed).SprintFunc()
    fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))

    info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
    fmt.Printf("This %s rocks!\n", info("package"))

    // Use helper functions
    fmt.Println("This", color.RedString("warning"), "should be not neglected.")
    fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")

    // Windows supported too! Just don't forget to change the output to color.Output
    fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))



您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code