win下 vscode 配置go

  1. 安装 go.msi

  2. 配置 GOPATH
    先在本地建立文件夹

     src			存放源代码
     
     pkg			编译过后生成的包文件
     
     bin			编译后生产的可执行文件和go相关的工具
     				把此目录加入Path环境变量下方便go的使用
    

win下 vscode 配置go_第1张图片
在环境变量中添加该目录路径
win下 vscode 配置go_第2张图片
注意用户环境中是否有相同的配置

  1. vs code中配置
    在这里插入图片描述
    在这里插入图片描述
    win下 vscode 配置go_第3张图片
    配置 git 路径
    "git.path": "‪D:/Program Files/Git/cmd/git.exe",

    // go
    "go.buildOnSave": "workspace",
    "go.lintOnSave": "package",
    "go.vetOnSave": "package",
    "go.buildTags": "",
    "go.buildFlags": [],
    "go.lintFlags": [],
    "go.vetFlags": [],
    "go.coverOnSave": false,
    "go.useCodeSnippetsOnFunctionSuggest": false,
    "go.formatOnSave": true,
    "go.formatTool": "goreturns",
    "go.goroot": "C:\\Go",
    "go.gopath": "F:\\GoPath",
    "go.gocodeAutoBuild": false,
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "workbench.iconTheme": "vscode-icons",

注意用 斜杠/ 或 反斜杠\\

  1. go env 查看配置

  2. 添加 go 的 tools

    先新建文件夹
    win下 vscode 配置go_第4张图片
    再切换到 x 目录下,下载插件包
    git clone https://github.com/golang/tools.git tools

然后下载需要的模块

go install github.com/ramya-rao-a/go-outline
    go install github.com/acroca/go-symbols
    go install golang.org/x/tools/cmd/guru
    go install golang.org/x/tools/cmd/gorename
    go install github.com/josharian/impl
    go install github.com/rogpeppe/godef
    go install github.com/sqs/goreturns
    go install github.com/golang/lint/golint
    go install github.com/cweill/gotests/gotests
    go install github.com/ramya-rao-a/go-outline
    go install github.com/acroca/go-symbols
    go install golang.org/x/tools/cmd/guru
    go install golang.org/x/tools/cmd/gorename
    go install github.com/josharian/impl
    go install github.com/rogpeppe/godef
    go install github.com/sqs/goreturns
    go install github.com/cweill/gotests/gotests

你可能感兴趣的:(go)