refactoring in Go - rather pleasant actually...

12 Feb 2013

I’ve just finished refactoring a large Go program, and the process was rather…. pleasant.

Static typing catches all those obscure errors I wouldn’t think about in a scripting language (Python, Perl, Ruby, etc). My process is:

  • type :make in vim (I have a dummy Makefile in my Go project just for vim)
  • vim jumps cursor to error (vim quickfix list)
  • “oh, I shouldn’t do that” - fix (type type type)
  • start again

Finish rather sooner than expected, run tests, smile in knowledge program is working properly.


To quickly setup the make command for Go, type this in a Vim window:

:setlocal makeprg=go\ build\ \.

Or even better configure vim via your ~/.vimrc, for example:

autocmd BufRead *_test.go setlocal makeprg=go\ test\ \.
autocmd BufRead *.go setlocal makeprg=go\ test\ \./..

Thanks Martin for the comment!

comments powered by Disqus

  « Previous: Next: »