23

给vscode配置golang环境

 4 years ago
source link: https://studygolang.com/articles/27981
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

最近在折腾一个后台管理,准备用node.js的koa框架开发后端,突然脑抽筋想用go来写,一方面想学习一下go,另一方面闲的。go的开发工具,网上搜了一下,有 goLandLiteIDE ,当然也有在Eclipse和vs code下通过插件来配置go的开发环境。对于vs code 我太喜欢了,那肯定要用vs code啊,但是它的配置有些坑,于是又在网上冲浪半天,我把具体环境配置记录下来。

目录

  • 安装golang
  • 安装vs code go插件
  • 安装其他智能提示、代码补全等相关插件

安装golang

下载 golang (自己选择合适的,这里我选 go1.13.5.windows-amd64.msi ,直接安装就行了)

安装好,默认环境变量也配置好了,命令行运行 go version 查看是否正确,若提示错误,检查一下环境变量,默认路径 C:\Go\bin ,添加到path中就好了

安装 vs code插件

直接在vs code插件商店,查找go,安装即可

安装其他智能提示、代码补全等相关插件

新建一个 xx.go 文件,打开vs code 会提示你安装相关插件。

注意,这里点击安装,会提示安装失败,具体啥原因,咱也不敢问。下面我们自己安装

  1. 在go安装路径: C:\Go\src 下 新建一个golang.org文件,打开该文件新建一个x文件夹
  2. C:\Go\src/golang.org/x 目录下,通过git安装 tools 插件
git clone https://github.com/golang/tools.git
  1. 在安装lint
git clone https://github.com/golang/lint.git
  1. 在当前x目录下运行下面命令
go get golang.org/x/lint/golint
  1. 重启vs code ,打开先前的 xx.go 文件,提示安装相关插件,选择安装,提示安装成功

ok,现在我们就可以在vs code中愉快的开发go应用了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK