Recently, I’ve taken an interest in the Go language and one of its more significant web frameworks called Beego. I wanted to do all my development work in Linux (my main computer is a Mac running OS X “Mavericks”), so I installed VirtualBox and created a VM for Ubuntu Server 14.04 “Trusty Tahr.” I chose the Server Edition because Ubuntu was also going to host the web server for my Go web applications.
Now, the Server Edition is a command line environment — there’s no fancy graphical interface to make things easy for you. But I wanted to make coding as convenient as I could, and derive as many benefits of a GUI-based IDE as possible. Here’s how I did it…
To begin with, install Go and Beego. Make sure you set the GOROOT environment variable for convenience sake.
The editing tool will be Vim, a venerable Unix editor with a rather bizarre command structure. I happen to be familiar with Vi (its predecessor), so it was a natural choice for me. To make Vim more Go-aware, I had to use some special plugins; the instructions for how to do this are hard to find in one place, so here they are:
First, create the following directories in your HOME directory:
Second, copy $GOROOT/misc/vim/syntax/go.vim to .vim/syntax and create a file .vim/ftdetect/go.vim with the line:
au BufRead,BufNewFile *.go set filetype=go
Third, create .vim/.vimrc and add these lines:
filetype plugin indent off
filetype plugin indent on
Vim is now ready for Go editing, giving you things like colour syntax, auto-indentation, and brace bracket matching.
I also wanted a handy way to navigate the directory structure of the Beego projects. Conventional GUI-based IDEs do this naturally, of course, but in a command line environment, what do you do? Enter Midnight Commander, or mc, for short.
Installing mc in Ubuntu is trivially easy:
sudo apt-get install mc
Finally, doing development work in a tiny 80x24 console window is a bit claustrophobic, so I wanted to increase the console screen size. Since my VM was using the grub bootloader, the simplest thing to do was:
- edit /etc/default/grub
- find the line “GRUB_CMDLINE_LINUX_DEFAULT=” and add “vga=791”
- exit the editor and run “update-grub”
This gives me a luxurious 128x48 console window.
There, we’re done! We have a pretty respectable character-based IDE for Go development on (Ubuntu) Linux. It’s not as fancy as those GUI-based IDEs, but all of this bring back fond memories of the days when I played with MS-DOS. Those were exciting times! Today, we are so pampered by GUIs that we’re virtually numb from being spoiled. I miss the old days (in the 1980s and early 1990s).