I struggle to write code.

Not because of the complexity of the challenge I’m trying to solve. Ha! If only that were the case.

When I write code, it definitely has to be haute. So beautiful, elegant, and downright pretty you forget why you were looking at it it’s so pretty.

One of my own personal nitpick tendencies is import sorting in Go. Any time I clone a new repo or contribute to a project, generally my first commit looks something like this:

When a friend of mine posted this question on twitter, I started to look at my own projects and tools for an answer.

Normally, go projects set up the usual either using vim-go or a File Watcher for one of the IntelliJ products.

Here’s an example of the File Watcher from Goland:

What this does, is when a file is edited and subsequently saved Goland will immediately run on that file in order to cleanup any erroneous spacing or improperly formatted code.

Why isn’t this enough?

You might be thinking, “but doesn’t sort imports?” Yes, yes it does. But if you have core, external, and internal packages all bunched together it will merely sort them alphabetically.

Ignoring the fact that I’m not willing to muddy up a for a medium article, here’s an example of the type of sorting does for you:

ewww.. imports

How can I make it haute?

Luckily, Goland already has a built in File Watcher so it’s much simpler than you think.

Here’s an example File Watcher configuration on a real project i’m currently working on:

The only real bit of customization here is the addition of to the arguments line of .

This configuration produces haute imports for a given Go file, again ignoring the fact that I’m not willing to muck about with a perfectly good :

One of the hidden features of is that it will also your code under the hood so you can choose to standardize solely on for your projects and get the best of both worlds.

This is just the tip of the haute iceberg. Stay tuned for more stories like this to really round out the Titanic-ness of super haute code.

I throw clouds at people.