Goland編輯器設(shè)置選擇范圍背景色的操作
為了區(qū)分選擇與未選擇區(qū)域,,將已選擇區(qū)域的文本背景色設(shè)置為淺藍(lán)色是個(gè)很做法。
設(shè)置的路徑在 Editor > Color Scheme > General > Editor > Selection background
下面以2018版的Goland為例,如圖:
JetBrains出品的如phpStorm和webStorm等的設(shè)置也基本如此。
補(bǔ)充:Go語(yǔ)言:控制臺(tái)輸出有顏色的字
本方法只限用于 Windows系統(tǒng)
應(yīng)用場(chǎng)景
需要輸出大量信息的運(yùn)行日志(一般是服務(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`) // 給字體顏色對(duì)象賦值 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 // 藍(lán)色 green int // 綠色 cyan int // 青色 red int // 紅色 purple int // 紫色 yellow int // 黃色 light_gray int // 淡灰色(系統(tǒng)默認(rèn)值) gray int // 灰色 light_blue int // 亮藍(lán)色 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(`藍(lán)色`, FontColor.blue) ColorPrint(`白色`, FontColor.white) }
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章
Golang中crypto/rand庫(kù)的使用技巧與最佳實(shí)踐
在Golang的眾多隨機(jī)數(shù)生成庫(kù)中,crypto/rand?是一個(gè)專為加密安全設(shè)計(jì)的庫(kù),本文主要介紹了Golang中crypto/rand庫(kù)的使用技巧與最佳實(shí)踐,感興趣的可以了解一下2024-02-02Go語(yǔ)言中的goroutine和channel如何協(xié)同工作
在Go語(yǔ)言中,goroutine和channel是并發(fā)編程的兩個(gè)核心概念,它們協(xié)同工作以實(shí)現(xiàn)高效、安全的并發(fā)執(zhí)行,本文將詳細(xì)探討goroutine和channel如何協(xié)同工作,以及它們?cè)诓l(fā)編程中的作用和優(yōu)勢(shì),需要的朋友可以參考下2024-04-04如何理解Go函數(shù)是一等公民原理及使用場(chǎng)景
這篇文章主要為大家介紹了如何理解Go函數(shù)是一等公民及使用場(chǎng)景詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07