A small collection of IntelliJ tips and tricks for getting more out of your day or simply doing the same amount for work with less effort.
1. Install the IntelliJ Go plugin from here
2. Project structure
3. Editor defaults
This one won’t necessarily speed you up but it should make life a little more comfortable.
4. Testing (and formating)
While I am not a TDD fanatic, I do like to run my tests quite often. I use the “Run Test” feature in IntelliJ to also format and fix the imports. To do this:
5. Live Templates
This is perhaps the best way to make yourself more efficient (excluding learning and using keyboard shortcuts). Live Templates allow you to specify “shortcuts” that you can quickly turn into blocks of code.
For example if you type “forr” and press Tab it will insert:
The thing most likely to trip you up when creating your own Live Templates is the “Applicable in Go: xxx” setting at the bottom of the panel (see below).
Generally, to insert “top level” elements like structs & interface definitions or functions then use “Go file”. To insert chunks of code inside a function use “Go block”. I have not personally used the other two options.
Here are some others that you might like:
I like to use the Testify lib for my tests so I find these particularly useful.