gpt4 book ai didi

Golang VSCode 配置最佳设置

转载 作者:行者123 更新时间:2023-12-01 19:25:21 24 4
gpt4 key购买 nike

我想知道是否有人可以在 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 设置的一些信息:
  • 版本: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 的文件夹
  • 最佳答案

    你可以试试这个设置。

        "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
            },
    },

    关于Golang VSCode 配置最佳设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60497980/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com