Ubuntu下通过官方归档安装Go后vim-go插件无法正常工作
Hey there, let's tackle this vim-go problem you're facing—those missing tool errors are super common when setting up Go with Vim, so we'll get it sorted out quickly!
First: Verify Your Go Environment Variables
The root cause often boils down to incorrect Go path configuration, which prevents vim-go from finding (or installing) the required binaries. Let's check and fix that first:
- Open your shell's config file (like
~/.bashrc,~/.zshrc, or~/.profile) in a text editor. - Add these lines if they're missing (adjust
GOPATHto your preferred directory if needed):export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin - Save the file and reload the config with:
source ~/.bashrc # or the file you edited - Confirm the paths are set correctly by running:
You should see both paths in the output.echo $GOPATH echo $PATH | grep -E "(go/bin|/usr/local/go/bin)"
Manually Install Missing Tools
Sometimes :GoInstallBinaries fails due to network issues or outdated repo paths. Let's install the problematic tools directly:
1. Install gotags
Run this command in your terminal (this pulls the official, up-to-date gotags repo):
go get github.com/jstemmer/gotags
2. Install golint
The golint repo has moved over time, so use the correct path:
go get golang.org/x/lint/golint
If you hit network errors (like being unable to reach golang.org), set a Go proxy first:
export GOPROXY=https://goproxy.io,direct go get golang.org/x/lint/golint
Final Step: Run :GoInstallBinaries Again
Once the above tools are installed, open Vim again and run:
:GoInstallBinaries
This should now install any remaining vim-go dependencies without errors.
Bonus: Update vim-go
Make sure your vim-go plugin is up to date. If you're using a plugin manager like vim-plug, run:
:PlugUpdate vim-go
Or use the update command for your specific manager (Vundle, Pathogen, etc.).
内容的提问来源于stack exchange,提问作者v v

