亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

staticcheck 不希望地檢查直接目錄之外的項目

staticcheck 不希望地檢查直接目錄之外的項目

Go
拉風的咖菲貓 2022-10-24 16:16:23
staticcheck不希望地掃描直接目錄樹之外的代碼。如何讓 staticcheck 僅掃描直接目錄樹,并忽略內部內容,例如: /usr/local/go/src/runtime/internal/sys/?我在staticcheck.io上搜索了文檔,但沒有找到任何關于這種行為的信息。例子:$ find . -name "*.go"./main.go./exporter/gather.go./exporter/metrics.go./exporter/structs.go./exporter/http.go./exporter/prometheus.go./config/config.go./bitbucket-exporter_test.go$ staticcheck ./.../usr/local/go/src/runtime/internal/sys/arch.go:24:7:    other declaration of PtrSize (compile)/usr/local/go/src/runtime/internal/sys/arch.go:27:7:    other declaration of StackGuardMultiplier (compile)/usr/local/go/src/runtime/internal/sys/stubs.go:9:7: PtrSize redeclared in this block (compile)/usr/local/go/src/runtime/internal/sys/stubs.go:10:24: undeclared name: Uintreg (compile)/usr/local/go/src/runtime/internal/sys/stubs.go:16:7: StackGuardMultiplier redeclared in this block (compile)$ staticcheck -versionstaticcheck 2021.1 (v0.2.0)$ go versiongo version go1.17.4 linux/amd64
查看完整描述

1 回答

?
12345678_0001

TA貢獻1802條經驗 獲得超5個贊

環境好像有問題。在單獨的 Ubuntu 機器上,安裝了 go 和 staticcheck,staticcheck 現在按預期運行:


$ staticcheck ./...

config/config.go:114:6: func getAuth is unused (U1000)

exporter/http.go:38:2: should use for range instead of for { select {} } (S1000)

exporter/http.go:55:6: func getEarlierDaysMs is unused (U1000)

exporter/http.go:70:10: error strings should not be capitalized (ST1005)

exporter/http.go:79:10: error strings should not be capitalized (ST1005)

exporter/http.go:84:10: error strings should not be capitalized (ST1005)

exporter/http.go:84:10: error strings should not end with punctuation or a newline (ST1005)

exporter/http.go:88:10: error strings should not be capitalized (ST1005)

exporter/http.go:88:10: error strings should not end with punctuation or a newline (ST1005)

exporter/http.go:92:10: error strings should not be capitalized (ST1005)

exporter/http.go:92:10: error strings should not end with punctuation or a newline (ST1005)

exporter/structs.go:101:12: unknown JSON option "int64" (SA5008)

$ go version

go version go1.17.4 linux/amd64

$ staticcheck --version

staticcheck 2021.1.2 (v0.2.2)

更多調查顯示,最有可能的是,以前的文件版本保持不變的臟升級可能導致 staticcheck 出現此錯誤。卸載 go 和 staticcheck,確保刪除舊的$GOROOT(/usr/local/go在 linux 上),然后重新安裝 go 和 staticcheck,解決了問題。


查看完整回答
反對 回復 2022-10-24
  • 1 回答
  • 0 關注
  • 224 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號