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

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

gopls 為 github.com/Shopify/sarama 返回錯誤“gopls:

gopls 為 github.com/Shopify/sarama 返回錯誤“gopls:

Go
精慕HU 2022-11-28 14:41:30
我已經檢查了(在 commit 處)的main分支,但我注意到在 VS Code 中我不能像往常一樣“轉到定義”。如果我將鼠標懸停在 中的包名稱上,我會收到 linter 警告github.com/Shopify/sarama947343309601b4eb3c2fa3e7d15d701b503dd491 saramafunctional_consumer_group_test.goNo packages found for open file /Users/kurtpeek/go/src/github.com/Shopify/sarama/functional_consumer_group_test.go: <nil>.If this file contains build tags, try adding "-tags=<build tag>" to your gopls "buildFlags" configuration (see (https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags-string).Otherwise, see the troubleshooting guidelines for help investigating (https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md).go list(見下面的截圖)。從命令行,如果我嘗試訪問gopls該文件,我會收到類似的錯誤:> gopls check functional_consumer_group_test.go gopls: no packages returned: packages.Load error我懷疑這與該文件中的構建約束(https://pkg.go.dev/cmd/go#hdr-Build_constraints)有關,來自https://github.com/Shopify/sarama/blob/947343309601b4eb3c2fa3e7d15d701b503dd491 /functional_consumer_group_test.go#L1-L2,//go:build functional// +build functional但是,我不清楚如何修改我的 VS 代碼settings.json以通過這些構建約束。有誰知道如何構建這個功能測試?
查看完整描述

2 回答

?
天涯盡頭無女友

TA貢獻1831條經驗 獲得超9個贊

https://www.ryanchapin.com/configuring-vscode-to-use-build-tags-in-golang-to-separate-integration-and-unit-test-code/之后,我不得不.vscode/settings.json在存儲庫的根目錄并添加以下內容:

{

    "go.buildFlags": [

        "-tags=functional"

    ],

    "go.testTags": "functional",

}

現在 VS Code 在該文件中正常工作:

http://img1.sycdn.imooc.com//6384584b00019a4f10190568.jpg

查看完整回答
反對 回復 2022-11-28
?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

你試過go clean -cache嗎?

此鏈接可能會有所幫助: https ://github.com/golang/go/issues/42353


查看完整回答
反對 回復 2022-11-28
  • 2 回答
  • 0 關注
  • 572 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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