vim-go最佳实践

0.使用方法

gd 进入函数原始定义文件查看 Ctrl + N Ctrl + P

1.常见FAQ

YCM,第三方包没办法自动补全问题

1.环境变量没有设置完整 设置正确环境变量

export GOROOT=/usr/lib/go
export GOPATH=/root/workspace/goProjects
export GOBIN=$GOPATH/bin
export GOTOOLS=$GOROOT/pkg/tool
export PATH=$PATH:$GOBIN:$GOTOOLS

2.工具没有装全 vim中运行如下命令

#1.自动安装
:GoInstallBinaries
#2.手动安装(墙外)
export http_proxy=http://10.0.2.2:8118
export https_proxy=http://10.0.2.2:8118

go get -u golang.org/x/tools/cmd/goimports && \
go get -u golang.org/x/tools/cmd/oracle && \
go get -u golang.org/x/tools/cmd/gorename && \
go get -u github.com/golang/lint/golint && \
go get -u golang.org/x/tools/go/gcimporter && \
go get -u golang.org/x/tools/go/types && \
go get -u github.com/kisielk/errcheck && \
go get -u golang.org/x/tools/go/loader

https://github.com/bradfitz/goimports

2.基础环境配置

vim //编辑器

https://wiki.archlinux.org/index.php/Vim

vundle //Vim包管理器

https://github.com/gmarik/Vundle.vim

$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

gocode //语法

Add the following line to your .vimrc:

 " ================================
 " set diy configuration by Ryane
 " ================================
 " set golang
 Plugin 'nsf/gocode', {'rtp': 'vim/'}
 :syntax on

安装后执行:PluginInstall进行下载安装

微信扫一扫交流

作者:ryanemax
微信关注:ryanemax (刘雨飏)
本文出处:https://futurestack.cn/cookbook/tool/vim-go/
授权协议: CC BY-SA 4.0