Useful bootstrap checklist for Go Projects (334 words)

Mostly here because I keep forgetting all the things I want to put into a Go project when I start it. Collected into a list of things I actually need to do, tools to install and how to get things working.

This page is a work in progress and something I will add to as I remember things or discover something new.

Static Analysis

Install that and run golangci-lint run ./... from the root when checking in.

Use the above to mute issues raised such as using defer or ignoring json.Marshall errors.


If JSON is being used and turns up in traces an easy option is to use the following.

import (
    jsoniter ""

var json = jsoniter.ConfigCompatibleWithStandardLibrary

Run Tests

Remember you need … spread to have them run recursively.

go test ./...

Unique Codes

grep -r uniqueCode . | grep -o '"[a-z0-9]*"' | sort | uniq -c | grep -v '  1 '


Use zerolog for logging.

For every log message use the following format,

log.Error().Str(uniqueCode, "1d0223bc").Err(err).Msg("error with getting user from database")

Where uniqueCode is a constant defined somewhere as uniqueCode and then for the value use date | md5 | cut -c 1-8 to generate a unique code.

This allows for quick finding of the line that produced an error or message.

To confirm that unique codes are in fact unique use the following,

grep -r uniqueCode . | grep -o '"[a-z0-9]*"' | sort | uniq -c | grep -v '   1 '

Which will return values if something is not actually unique.

Setting logging up is pretty simple, with the following,

switch strings.ToLower(config.LogLevel) {
case "debug":
case "info":
case "error":


Use the following if targetting ARM Linux

GOOS=linux GOARCH=arm64 go build -ldflags="-s -w"

The build flag is there to reduce the size of the binary.


Use and be sure to set the following,

router := mux.NewRouter().StrictSlash(true)

to ensure that slashes are handled in an expected manner.