Go及vim环境搭建

安装golang

tar -zxvf go1.13.4.linux-amd64.tar.gz -C /usr/local/
更好的使用Go,需要设置环境变量

vim /etc/profile
在前面添加
export GOROOT=/usr/local/go
export GOPATH=/usr/lib/golang
export PATH=$PATH:$GOROOT/bin
(原路径后用冒号连接新路径)
立刻生效:
source /etc/bash_profile

设置goproxy

export GO111MODULE=on

阿里云:    
export GOPROXY=https://mirrors.aliyun.com/goproxy/

nexus社区:   
export GOPROXY=https://gonexus.dev

goproxy.io:
export GOPROXY=https://goproxy.io/

基于athens的公共服务:
export GOPROXY=https://athens.azurefd.net

官方:
export GOPROXY=https://gocenter.io
export GOPROXY=https://proxy.golang.org

七牛:
export GOPROXY=https://goproxy.cn
go env -w GOPROXY=https://goproxy.cn,direct

更新vim

apt-get remove --purge vim
add-apt-repository ppa:jonathonf/vim
apt update
apt install -u vim

私有仓库自动忽略验证


设置GOPRIVATE来跳过私有库,比如常用的Gitlab或Gitee,中间使用逗号分隔:
goenv-w GOPRIVATE=*.gitlab.com,*.gitee.com

私有库忽略验证:
go env -w GOSUMDB=off

国内验证:
go env -w GOSUMDB="sum.golang.google.cn"

安装vim-go


git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go

将以下内容复制到 ~/.vimrc文件中
set nocompatible " be iMproved, required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'Valloric/YouCompleteme'

" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required

在vim命令模式下输入PluginInstall
在vim命令模式下输入GoInstallBinaries安装一些vim-go插件所需要的一些工具,这些工具会被放到$GOBIN目录下
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值