vscode golang 开发环境搭建

2019-12-10  本文已影响0人  onmeiei

因为不花钱的goland毕竟不是正途,所以耗点精力搭建基于vscode的开发环境是有必要的。

跟着本文,你可以得到

  1. docker开发环境
  2. vscode + ssh
  3. 远程golang语言服务器

docker

添加 --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
# go1.13+换用go env -w 方式设置,加下文。

export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH:$HOME/.local/bin

注:七牛网,真好人啊。https://goproxy.cnhttps://goproxy.io更稳定,速度更快。

$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
import写法

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

ctrl + shift + p 添加代码生成片段
上一篇 下一篇

猜你喜欢

热点阅读