There are a few ways to use it.

Combined with SublimeLinter, or run it each time you save a file.

You might be already running golint automatically at each file save with your code editor of choice — if you are not, you might be interested in my article about Sublime + Go — then you could replace golint by gometalinter.

This sounds like a bad idea though, first because of performance, after all running 11 tools takes its toll, but also because it only reports in the console what’s wrong.

Reports, right. Meaning you can ignore it, and chances are that you will.

Continuous Integration

If the checks are made in your CI job though, you won’t be able to ignore it. Nothing more convincing than a big red FAIL.

I’ve been trying out lately a very promising database called CockroachDB, its Makefile is very interesting.

The following is an adapted version which runs gometalinter recursively.

.PHONY: check

check:

@echo "gometalinter"

@! gometalinter ./... | \

grep -vE '(Godeps|vendor)'

@echo "gofmt (simplify)"

@! gofmt -s -d -l . 2>&1 | grep -vE '^\.git/'

@echo "goimports"

@! goimports -l . | grep -vF 'No Exceptions'

Once you’ve added this in your Makefile, you can try it out by running make check. You’ll notice that any output will generate an error, effectively preventing the check from finishing.

Now, only one step left, adding it to your CI server.

In CircleCI, it’s as simple as that:

test:

override:

— make build

— make check

— make test

Once these checks are integrated into your CI server, failing to comply with these checks will result in a broken build!

Pre-commit hook

Edit: as mentioned by jerf on the reddit thread, using a pre-commit hook is also a perfectly valid way of running the checks.

I would still recommend running the checks on the CI server for engineering teams.