archLinux 快速搭建golang开发环境

# 安装配置codeserver

1
2
yay -S code-server
sudo systemctl enable --now code-server@$USER

默认地址:http://127.0.0.1:8080 配置文件在 ~/.config/code-server/config.yaml 简单修改允许外网访问,并在路由做好端口转发 或者nginx ssl代理

1
2
3
4
bind-addr: 0.0.0.0:8080
auth: password
password: 密码
cert: false

重启

1
sudo systemctl restart code-server@$USER

# 安装go

建议手动安装 :https://dev.leiyanhui.com/c/ubuntu-install-golang/
pacman 安装也可以sudo pacman -S go

# 非root用户的处理

1
2
cd ~
mkdir .gocache

编辑 /etc/profile 或者用户目录下.profile文件

1
export GOCACHE=/home/用户名/.gocache

完整内容

1
2
3
4
5
6
7
export GO111MODULE=on
export GOROOT=/opt/go
export GOPATH=/opt/gopath
#export GOCACHE=/opt/gocache
export GOCACHE=/home/用户名/.gocache
export GOPROXY=https://proxy.golang.com.cn,direct
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

# 配置codeserver的go插件

注意点,如当前用户权限不够,需要su到root下执行,sudo执行 会有网络超时的问题 https://dev.leiyanhui.com/codeserver/vscode-golang-err-gocache/

# 测试一个项目

1
2
3
4
mkdir golang && cd golang
git clone https://github.com/joyanhui/webdavgo.git
su #切换到root
go get golang.org/x/net/webdav  #webdav

coderserver 打开运行测试

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计