亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    go語言如何改變回顯顏色

    go語言改變回顯顏色的方法:首先打開相應(yīng)的go文件;然后通過“FontColor Color=Color{}”方法給字體顏色對象賦值;最后通過“func ColorPrint(s string, i int){}”方法輸出有顏色的字體即可。

    go語言如何改變回顯顏色

    本文環(huán)境:Windows7系統(tǒng)、Go1.11.2版,本文適用于所有品牌的電腦。

    推薦:《golang教程

    golang控制臺顏色輸出(for windows)

    Go語言:控制臺輸出有顏色的字

    本方法只限用于 Windows系統(tǒng)

    應(yīng)用場景

    需要輸出大量信息的運行日志(一般是服務(wù)器,Windows系統(tǒng)的)

    某類客戶端的調(diào)試界面(一般是游戲,特別是有第三方模組的)

    代碼示例

    package main   import (     "syscall" )   var (     kernel32    *syscall.LazyDLL  = syscall.NewLazyDLL(`kernel32.dll`)     proc        *syscall.LazyProc = kernel32.NewProc(`SetConsoleTextAttribute`)     CloseHandle *syscall.LazyProc = kernel32.NewProc(`CloseHandle`)       // 給字體顏色對象賦值     FontColor Color = Color{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} )   type Color struct {     black        int // 黑色     blue         int // 藍色     green        int // 綠色     cyan         int // 青色     red          int // 紅色     purple       int // 紫色     yellow       int // 黃色     light_gray   int // 淡灰色(系統(tǒng)默認(rèn)值)     gray         int // 灰色     light_blue   int // 亮藍色     light_green  int // 亮綠色     light_cyan   int // 亮青色     light_red    int // 亮紅色     light_purple int // 亮紫色     light_yellow int // 亮黃色     white        int // 白色 }   // 輸出有顏色的字體 func ColorPrint(s string, i int) {     handle, _, _ := proc.Call(uintptr(syscall.Stdout), uintptr(i))     print(s)     CloseHandle.Call(handle) }   func main() {     ColorPrint(`紅色`, FontColor.red)     ColorPrint(`藍色`, FontColor.blue)     ColorPrint(`白色`, FontColor.white) }

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號