chore: arrange imports in a standard way (#21452)

Fixes all our Go file imports to match the preferred spec that we've _mostly_ been using. For example:

```
import (
	"context"
	"time"

	"github.com/prometheus/client_golang/prometheus"
	"golang.org/x/xerrors"
	"gopkg.in/natefinch/lumberjack.v2"

	"cdr.dev/slog/v3"
	"github.com/coder/coder/v2/codersdk/agentsdk"
	"github.com/coder/serpent"
)
```

3 groups: standard library, 3rd partly libs, Coder libs.

This PR makes the change across the codebase. The PR in the stack above modifies our formatting to maintain this state of affairs, and is a separate PR so it's possible to review that one in detail.
This commit is contained in:
Spike Curtis
2026-01-08 15:24:11 +04:00
committed by GitHub
parent b20d1bf159
commit bddb808b25
449 changed files with 340 additions and 872 deletions
+2 -4
View File
@@ -18,10 +18,6 @@ import (
"tailscale.com/tailcfg"
"cdr.dev/slog/v3"
"github.com/coder/retry"
"github.com/coder/websocket"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/apiversion"
"github.com/coder/coder/v2/coderd/httpapi"
@@ -29,6 +25,8 @@ import (
"github.com/coder/coder/v2/codersdk/drpcsdk"
"github.com/coder/coder/v2/tailnet"
tailnetproto "github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/retry"
"github.com/coder/websocket"
)
// ExternalLogSourceID is the statically-defined ID of a log-source that
-1
View File
@@ -13,7 +13,6 @@ import (
"tailscale.com/tailcfg"
"cdr.dev/slog/v3/sloggers/slogtest"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/testutil"
)
+1 -3
View File
@@ -9,13 +9,11 @@ import (
"sync"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/google/uuid"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/timestamppb"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/retry"
+1 -2
View File
@@ -20,10 +20,9 @@ import (
"go.opentelemetry.io/otel/semconv/v1.14.0/httpconv"
"golang.org/x/xerrors"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/coderd/tracing"
"github.com/coder/websocket"
"cdr.dev/slog/v3"
)
// These cookies are Coder-specific. If a new one is added or changed, the name
-1
View File
@@ -27,7 +27,6 @@ import (
"cdr.dev/slog/v3"
"cdr.dev/slog/v3/sloggers/sloghuman"
"github.com/coder/coder/v2/testutil"
)
+2 -4
View File
@@ -14,19 +14,17 @@ import (
"strings"
"time"
"github.com/coreos/go-oidc/v3/oidc"
"github.com/google/uuid"
"golang.org/x/mod/semver"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/xerrors"
"github.com/coreos/go-oidc/v3/oidc"
"github.com/coder/serpent"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/coderd/agentmetrics"
"github.com/coder/coder/v2/coderd/workspaceapps/appurl"
"github.com/coder/serpent"
)
// Entitlement represents whether a feature is licensed.
+1 -2
View File
@@ -14,10 +14,9 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"github.com/coder/serpent"
"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
)
type exclusion struct {
+2 -3
View File
@@ -8,11 +8,10 @@ import (
"sort"
"strings"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/zclconf/go-cty/cty"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
)
/**
-1
View File
@@ -14,7 +14,6 @@ import (
"golang.org/x/xerrors"
"github.com/coder/aisdk-go"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/codersdk"
)
+1 -2
View File
@@ -6,9 +6,8 @@ import (
"fmt"
"strings"
"golang.org/x/xerrors"
"github.com/google/uuid"
"golang.org/x/xerrors"
"github.com/coder/aisdk-go"
"github.com/coder/coder/v2/codersdk"
-1
View File
@@ -15,7 +15,6 @@ import (
"golang.org/x/xerrors"
"github.com/coder/aisdk-go"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/coderd/workspaceapps/appurl"
+1 -2
View File
@@ -21,9 +21,8 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"github.com/coder/aisdk-go"
agentapi "github.com/coder/agentapi-sdk-go"
"github.com/coder/aisdk-go"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agenttest"
"github.com/coder/coder/v2/coderd/coderdtest"
+1 -2
View File
@@ -7,9 +7,8 @@ import (
"net/http"
"time"
"golang.org/x/xerrors"
"github.com/google/uuid"
"golang.org/x/xerrors"
)
type ProxyHealthStatus string
-1
View File
@@ -12,7 +12,6 @@ import (
"golang.org/x/xerrors"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/coderd/tracing"
)
-1
View File
@@ -22,7 +22,6 @@ import (
"tailscale.com/net/speedtest"
"cdr.dev/slog/v3"
"github.com/coder/coder/v2/coderd/tracing"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/healthsdk"
+1 -3
View File
@@ -11,13 +11,11 @@ import (
"golang.org/x/xerrors"
"cdr.dev/slog/v3"
"github.com/coder/websocket"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)
var permanentErrorStatuses = []int{
-1
View File
@@ -17,7 +17,6 @@ import (
"cdr.dev/slog/v3"
"cdr.dev/slog/v3/sloggers/slogtest"
"github.com/coder/coder/v2/apiversion"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
+4 -7
View File
@@ -12,20 +12,17 @@ import (
"strconv"
"strings"
"github.com/google/uuid"
"golang.org/x/xerrors"
"tailscale.com/tailcfg"
"tailscale.com/wgengine/capture"
"github.com/google/uuid"
"golang.org/x/xerrors"
"cdr.dev/slog/v3"
"github.com/coder/quartz"
"github.com/coder/websocket"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/quartz"
"github.com/coder/websocket"
)
var ErrSkipClose = xerrors.New("skip tailnet close")
+1 -2
View File
@@ -15,13 +15,12 @@ import (
"tailscale.com/net/tsaddr"
"tailscale.com/tailcfg"
"github.com/coder/websocket"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/workspacesdk"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/testutil"
"github.com/coder/websocket"
)
func TestWorkspaceRewriteDERPMap(t *testing.T) {
-1
View File
@@ -6,7 +6,6 @@ import (
"sync/atomic"
"cdr.dev/slog/v3"
"github.com/coder/websocket"
)
-1
View File
@@ -2,7 +2,6 @@ package wsjson
import (
"cdr.dev/slog/v3"
"github.com/coder/websocket"
)