Sorting Imports

Packages can be divided in to three types, standard library, our own packages, and third party packages.

Imports should be grouped accordingly, with the standard library packages first, followed by packages starting with github.com/cirruscomms/ and then third party packages.

Examples
imports.go
 1package main
 2
 3import (
 4	"context"
 5	"flag"
 6	"fmt"
 7	"net/http"
 8
 9	"github.com/cirruscomms/go-common/pkg/db/migrations"
10	"github.com/cirruscomms/go-common/pkg/env/config"
11	"github.com/cirruscomms/go-logging"
12	etc "github.com/cirruscomms/optus-service/etc/migrations"
13	"github.com/cirruscomms/optus-service/internal/api"
14	"github.com/cirruscomms/optus-service/internal/api/base"
15	"github.com/cirruscomms/optus-service/internal/optus"
16	actions "github.com/cirruscomms/optus-service/internal/optusActions"
17
18	"github.com/joho/godotenv"
19	"github.com/sirupsen/logrus"
20)
IDE Configuration

This can be achieved auto-magically by configuring your IDE and/or Go’s language server to use gofumpts as the formatter for Go files.

For VS Code with formatting handled by gopls the settings are:

settings.json
 1{
 2    "gopls": {
 3        "analyses": {
 4            "nilness": true,
 5            "shadow": false,
 6            "unusedvariable": true,
 7            "useany": true,
 8        },
 9        "codelenses": {
10            "run_govulncheck": false
11        },
12        "formatting.gofumpt": true,
13        "formatting.local": "github.com/cirruscomms/",
14        "staticcheck": true,
15        "ui.semanticTokens": true
16    },
17}