Sublime Text Workflow: Auto Build & Format

· 188 words · 1 minute read

Sublime Text 3 can be a great editor for writing Go code - and with a few simple tweaks it can get better. One example of a simple workflow improvement to automate the running of go fmt each time you save. This keeps your code neat and tidy, while also alerting you to any syntax errors.

Some things you’ll need to get started:

  • Go installed (with a GOPATH)
  • Sublime Text Installed

1) Install Package Control

Firstly, we’ll install Sublime’s Package Control by going to their site: packagecontrol.io/installation. There’s some code to copy and paste which should install it all for you. If you haven’t used this plugin before it makes installing plugins within Sublime Text very easy.

2) Install Build

Within Sublime, if we now:

  • Type: Ctrl + Shift + P
  • Start typing and select ‘Package Control: Install Package’
  • Install the sublime-build package by typing: ‘Golang Build’

check is date set or not

We can manually build now by pressing Ctrl + B, which will show a popup at the bottom to confirm it’s run. But also, each time to hit Ctrl + S to save, it will also format your code for you.

Image of Author Edd Turtle

Author:  Edd Turtle

Edd is the Lead Developer at Hoowla, a prop-tech startup, where he spends much of his time working on production-ready Go and PHP code. He loves coding, but also enjoys cycling and camping in his spare time.

See something which isn't right? You can contribute to this page on GitHub or just let us know in the comments below - Thanks for reading!