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

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

Golang VSCode 配置最佳設置

Golang VSCode 配置最佳設置

Go
幕布斯6054654 2022-05-18 16:28:25
我想知道是否有人可以在 Mac 上使用 Vscode 分享他們對 Golang 的最佳設置。由于我不斷遇到以下問題:有時 gomft 不起作用。在同一包中定義的函數顯示帶有紅色下劃線警告,表示它未定義(但在運行時有效)彈出以下消息Your workspace is misconfigured: command-line-arguments has no metadata. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.以下是我的 go setup 的一些信息:版本:go1.13.4 darwin/amd64“settings.json”中的設置:    {        "window.zoomLevel": 1,        "workbench.iconTheme": "material-icon-theme",        "editor.accessibilitySupport": "off",        "go.useLanguageServer": true,        "go.formatTool": "gofmt",        "go.lintTool": "golangci-lint",        "[go]": {            "editor.formatOnSave": true,            "editor.codeActionsOnSave": {                "source.organizeImports": true            },        },        "explorer.confirmDragAndDrop": false,        "javascript.updateImportsOnFileMove.enabled": "always",        "diffEditor.ignoreTrimWhitespace": false    }GOPATH 指向安裝 Go 的文件夾
查看完整描述

3 回答

?
泛舟湖上清波郎朗

TA貢獻1818條經驗 獲得超3個贊

你可以試試這個設置。


    "go.inferGopath": false,

    "go.buildOnSave": "workspace",

    "go.lintOnSave": "package",

    "go.vetOnSave": "package",

    "go.buildTags": "",

    "go.buildFlags": [],

    "go.lintFlags": [],

    "go.vetFlags": [],

    "go.coverOnSave": false,

    "go.useCodeSnippetsOnFunctionSuggest": false,

    "go.formatTool": "goreturns",

    "go.gocodeAutoBuild": false,

    "go.useLanguageServer": true,

    "go.alternateTools": {

      "go-langserver": "gopls", 

    },

    "go.languageServerExperimentalFeatures": {

      "format": true,

      "autoComplete": true

    },

    "[go]": {

        "editor.codeActionsOnSave": {

            "source.organizeImports": true

        },

    },


查看完整回答
反對 回復 2022-05-18
?
子衿沉夜

TA貢獻1828條經驗 獲得超3個贊

go.useLanguageServer: false,可能對你有幫助



查看完整回答
反對 回復 2022-05-18
?
婷婷同學_

TA貢獻1844條經驗 獲得超8個贊

我看到了同樣的問題,也使用golangci-lint了 lint 工具。當我查看 Go 擴展的輸出時(視圖 > 命令托盤 > 輸出:關注輸出視圖;然后在輸出視圖的下拉列表中選擇“Go”),我看到如下錯誤:


Error while running tool: /usr/local/bin/golangci-lint run --print-issued-lines=false

level=warning msg="[runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: [email protected]/pkg/example"

還有這個


level=error msg="Running error: buildssa: analysis skipped: errors in package: [/Users/tschaub/projects/pkg/example.go:6:15: undeclared name: SomethingIJustStartedTyping

第一個錯誤 ( assign: failed prerequisites) 在https://github.com/golangci/golangci-lint/issues/827中被記錄,并以關于更新到[email protected].


第二個錯誤 ( ) 已在https://github.com/golangci/golangci-lint/issues/896buildssa: analysis skipped出票,并且在我輸入此內容時收到新的評論。


升級到 v1.24.0可能無法解決問題,但聽起來它可能會生成更具描述性的輸出。


即使使用[email protected]也不能解決我的問題。每當我進入這種“錯誤配置”狀態時,我都需要退出 VSCode 并重新啟動它。我希望在工具趕上 go 模塊之后,事情會更加穩定/可靠。


查看完整回答
反對 回復 2022-05-18
  • 3 回答
  • 0 關注
  • 317 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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