vscode golang 开发环境搭建
onmeiei · · 1454 次点击 · · 开始浏览因为不花钱的goland毕竟不是正途,所以耗点精力搭建基于vscode的开发环境是有必要的。
跟着本文,你可以得到
- docker开发环境
- vscode + ssh
- 远程golang语言服务器
docker
- 注意事项: 默认docker不支持fork,所以vscode F5 debug会报错。
添加 --security-opt=seccomp:unconfined参数来允许容器执行全部的系统的调用可以解决这个问题
docker run --security-opt=seccomp:unconfined --name wmw-ubuntu-18.04 -p 20022:22 -it ubuntu /bin/bash
安装go
修改.bashrc,添加如下内容
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
# 强制开启module模式
export GO111MODULE=on
# 配置Proxy之后,就可以愉快的go get了
export GOPROXY=https://goproxy.io
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH:$HOME/.local/bin
- 注:开启
GO111MODULE之后,则引用本地package时,不能再使用相对路径了。
vscode
安装插件
Local安装
Name: Remote - SSH
Id: ms-vscode-remote.remote-ssh
Description: Open any folder on a remote machine using SSH and take advantage of VS Code's full feature set.
Version: 0.47.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh
Name: Remote - SSH: Editing Configuration Files
Id: ms-vscode-remote.remote-ssh-edit
Description: Edit SSH configuration files
Version: 0.47.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh-edit
Remote安装
Name: Go
Id: ms-vscode.go
Description: Rich Go language support for Visual Studio Code
Version: 0.11.9
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
Make things better
- 编辑代码生成
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
因为不花钱的goland毕竟不是正途,所以耗点精力搭建基于vscode的开发环境是有必要的。
跟着本文,你可以得到
- docker开发环境
- vscode + ssh
- 远程golang语言服务器
docker
- 注意事项: 默认docker不支持fork,所以vscode F5 debug会报错。
添加 --security-opt=seccomp:unconfined参数来允许容器执行全部的系统的调用可以解决这个问题
docker run --security-opt=seccomp:unconfined --name wmw-ubuntu-18.04 -p 20022:22 -it ubuntu /bin/bash
安装go
修改.bashrc,添加如下内容
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
# 强制开启module模式
export GO111MODULE=on
# 配置Proxy之后,就可以愉快的go get了
export GOPROXY=https://goproxy.io
export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH:$HOME/.local/bin
- 注:开启
GO111MODULE之后,则引用本地package时,不能再使用相对路径了。
vscode
安装插件
Local安装
Name: Remote - SSH
Id: ms-vscode-remote.remote-ssh
Description: Open any folder on a remote machine using SSH and take advantage of VS Code's full feature set.
Version: 0.47.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh
Name: Remote - SSH: Editing Configuration Files
Id: ms-vscode-remote.remote-ssh-edit
Description: Edit SSH configuration files
Version: 0.47.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh-edit
Remote安装
Name: Go
Id: ms-vscode.go
Description: Rich Go language support for Visual Studio Code
Version: 0.11.9
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
Make things better
- 编辑代码生成