使用下面方法,可以设置golang在windows终端的文本颜色。
颜色值请搜索SetConsoleTextAttribute

func ColorPrint(s string, i int) { //设置终端字体颜色
    kernel32 := syscall.NewLazyDLL("kernel32.dll")
    proc := kernel32.NewProc("SetConsoleTextAttribute")
    handle, _, _ := proc.Call(uintptr(syscall.Stdout), uintptr(i))
    fmt.Print(s)
    handle, _, _ = proc.Call(uintptr(syscall.Stdout), uintptr(7))
    CloseHandle := kernel32.NewProc("CloseHandle")
    CloseHandle.Call(handle)
}

//使用方法,直接调用即可输出带颜色的文本
ColorPrint("[OK];", 2|8) //亮绿色