Go Development in Ubuntu 16.04 Using Vim

In high level there are two ways to install the required golang and vim. The first approach is to use whatever version available in Ubuntu 16.04. The other approach is to use the latest version by using ppa.

Using Default Package from Current Ubuntu Version

Install Go

sudo apt install golang-go
Check the installed version by running go version.

Install Vim

sudo apt install vim
Check the installed version by running vim -version.

Install vim-go

vim-go is vim plugin that add some useful features for go development using vim.

To install, head to vim-go github for the detail. There are 3 methods to install vim-go:

  • Using vim 8 native package manager (in the next section)
  • Using vim-pathogen
  • Using vim-plug

Using vim-pathogen

Head to vim-pathogen github for the detail guideline. Basically we need to run this command below.

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Then edit the .vimrc file by adding this line below.

execute pathogen#infect()

Then install vim-go to be loaded by pathogen by executing this command.

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

To test the installation, open vim and try to run some vim-go command, such as :GoInstallBinnaries.

Using vim-plug

Another alternative for vim-go installation is by using vim-plug. The installation is as follow.

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \

Add this to .vimrc file.

call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
call plug#end()

Then open vim and execute :PlugInstall.

Using Latest Package

Install The Latest Go Version

Add the latest version of Go ppa.

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go

Install The Latest Vim Version

Add the latest ppa.

sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim

Install vim-go

Install Using vim8 native package manager

git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go

After finishing installation, the vim-go project has a good tutorial of how to use the plugin in details.