Use goimports to standardise imports
gofmt
which additionally adds (and removes) import lines as necessary.godoc
gofmt
go lint
Try to keep the normal code path at a minimal indentation, and indent the error handling, dealing with it first. This improves the readability of the code by permitting visually scanning the normal path quickly. For instance, don’t write:
if err != nil {
// error handling
} else {
// normal code
}