Mac 下 Vscode 配置 Golang 开发环境 - Go语言中文社区

Mac 下 Vscode 配置 Golang 开发环境


Mac 下 Vscode 配置 Golang 开发环境

settings.json 配置

{
    "python.defaultInterpreterPath": "/Users/yichuan.deng/mkt/env/bin/python",
    "editor.fontSize": 16,
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "python.pythonPath": "/Users/yichuan.deng/mkt/env/bin/python",
    "window.zoomLevel": 1,
    "explorer.confirmDelete": false,
    "python.formatting.autopep8Args": [
        "--indent-size=4"
    ],
    "go.inferGopath": true,
    "go.autocompleteUnimportedPackages": true,
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "go.gocodePackageLookupMode": "go",
    "go.gotoSymbol.includeImports": true,
    "go.docsTool": "gogetdoc",
    "go.gopath": "/Users/yichuan.deng/workspace/go",
    "go.goroot": "/Users/yichuan.deng/goroot",
    "go.formatTool": "goimports",
    "go.lintTool": "golint",
    "go.lintOnSave": "file",
    "go.useLanguageServer": true,
    "go.languageServerFlags": [],
    "files.autoSave": "off",
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": false
    },
    "terminal.external.linuxExec": "zsh",
    "terminal.integrated.fontSize": 16,
    "workbench.editorAssociations": [],
    "terminal.explorerKind": "external",
    "terminal.external.osxExec": "iTerm.app",
    "go.alternateTools": {
        "go-langserver": "gopls",
    },
    "go.languageServerExperimentalFeatures": {
        "diagnostics": true,
        "documentLink": true,
    },
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.fixAll": true,
            "source.organizeImports": true
        }
    },
    "editor.semanticTokenColorCustomizations": null,
    "editor.codeActionsOnSave": null,
    "workbench.colorTheme": "One Dark Pro",
    "workbench.iconTheme": "vscode-icons",
    "python.showStartPage": false,
    "settingsSync.ignoredSettings": [],
    "editor.fontLigatures": null,
}

Vscode Go Tools 安装

cmd+shift+P 选择 Go: Install/Update Tools

Install/Update Tools
选择全部,点击确定
安装

Vscode 推荐插件

  • Annotator
  • Chinese (Simplified) Language Pack for Visual Studio Code
  • Go
  • Rename terminal Button
  • Terminal Tabs
  • Git History Diff
  • json
  • Paste JSON as Codede

Vscode 调试 Golang

选择调试和运行
点击设置会弹出一个配置JSON,这个就是调试的时候的一些配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch file",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}" // 你的工作目录作为调试的根目录,也就是你的main.go 在的地方
           "env": { // 调试的时候的环境变量
                "env": "DEV",
                "tag": "yichuan",
                "IS_LOCAL_HOST": "true",
            },
        }
    ]
}

开始调试

告别Print调试大法
在这里插入图片描述

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/baidu_32452525/article/details/115273599
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢