go 常見問題

2021-09-20 01:35:30 字數 2605 閱讀 9120

以下是我在go專案中碰到問題

1. 如何只測試指定的test檔案,而不是所有的單元測試都跑一遍.

go tool vet -test -v src\github.com\astaxie\beego\controller_test.go

go tool vet 是個很不錯的工具,裡面有很強大的功能

go tool vet 引數

usage of vet:

vet [flags] directory...

vet [flags] files... # must be a single package

for more information run

godoc golang.org/x/tools/cmd/vet

flags:

-all

check everything; disabled if any explicit check is requested (default true)

-asmdecl

check assembly against go declarations (default unset)

-assign

check for useless assignments (default unset)

-atomic

check for common mistaken usages of the sync/atomic package (default unset)

-bool

check for mistakes involving boolean operators (default unset)

-buildtags

check that +build tags are valid (default unset)

-composites

check that composite literals used field-keyed elements (default unset)

-compositewhitelist

use composite white list; for testing only (default true)

-copylocks

check that locks are not passed by value (default unset)

-methods

check that canonically named methods are canonically defined (default unset)

-nilfunc

check for comparisons between functions and nil (default unset)

-printf

check printf-like invocations (default unset)

-printfuncs string

comma-separated list of print function names to check

-rangeloops

check that range loop variables are used correctly (default unset)

-shadow

check for shadowed variables (experimental; must be set explicitly) (default unset)

-shadowstrict

whether to be strict about shadowing; can be noisy

-shift

check for useless shifts (default unset)

-structtags

-tags string

-test

for testing only: sets -all and -shadow

-unreachable

check for unreachable code (default unset)

-unsafeptr

check for misuse of unsafe.pointer (default unset)

-unusedfuncs string

comma-separated list of functions whose results must be used (default "errors.new,fmt.errorf,fmt.sprintf,fmt.sprint,sort.reverse")

-unusedresult

check for unused result of calls to functions in -unusedfuncs list and methods in -unusedstringmethods list (default unset)

-unusedstringmethods string

comma-separated list of names of methods of type func() string whose results must be used (default "error,string")

-v verbose

常見問題 朗動常見問題

常見問題一 方向盤變沉 檢查胎壓是否正常,輪胎是否過度磨損。助力幫浦不工作,前輪氣壓低。冬天的話,冷車在冬天助力油比較稠,方向會重一點。檢查轉向助力油。1 應該是是助力系統有問題或則助力潤滑油有問題。2 如果你在駕車時感覺方向盤變緊,汽車偏向一側,需要檢查輪胎,或進行車輪平衡 定位。在這些問題剛剛發...

面試常見問題 1 this的常見問題

this 的含義 this關鍵字是乙個非常重要的語法點。毫不誇張地說,不理解它的含義,大部分開發任務都無法完成。前一章已經提到,this可以用在建構函式之中,表示例項物件。除此之外,this還可以用在別的場合。但不管是什麼場合,this都有乙個共同點 它總是返回乙個物件。簡單說,this就是屬性或方...

Spring常見問題

1 利用spring框架程式設計,console列印出log4j warn please initialize the log4j system properly?lupa開源社群 u i w.d t 說 明你的log4j.properties沒有配置。請把log4j.properties放到工程的...