当前位置:   article > 正文

Mac 下 Vscode 配置 Golang 开发环境_mac vscode golang

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,
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58

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",
            },
        }
    ]
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

开始调试

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/702410
推荐阅读
相关标签
  

闽ICP备14008679号