windows下cmd中怎样打印颜色?

leavesdrift · 2017-12-10 14:45:39 · 1727 次点击

最后找到了这个包,相对轻量

package main

import (
    "fmt"
    "github.com/mattn/go-colorable"
    "os"
)

func main(){
    stdout := colorable.NewColorable(os.Stdout)
    str := "cyan"
    fmt.Fprintf(stdout,"\x1b[36m%s\x1b[0m", str)
}
#2
更多评论

哈哈,那你就看下那个包怎么实现的咯。

#1