Skip to content

Commit 9addbff

Browse files
authored
Merge pull request #306 from dgageot/better-formatter
Better formatter
2 parents 5dd6ed4 + f054395 commit 9addbff

36 files changed

Lines changed: 89 additions & 54 deletions

.golangci.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ issues:
8787
max-same-issues: 3
8888
formatters:
8989
enable:
90+
- gci
9091
- gofmt
9192
- gofumpt
92-
- goimports
93-
exclusions:
94-
generated: lax
95-
paths:
96-
- .*_test\.go$
97-
- third_party$
98-
- builtin$
99-
- examples$
93+
settings:
94+
gci:
95+
custom-order: true
96+
sections:
97+
- standard
98+
- default
99+
- prefix(github.com/docker/cagent)
100+
gofmt:
101+
rewrite-rules:
102+
- pattern: 'interface{}'
103+
replacement: 'any'
104+
gofumpt:
105+
extra-rules: true

Taskfile.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ tasks:
3838

3939
lint:
4040
desc: Run golangci-lint
41-
cmd: golangci-lint run ./...
41+
cmd: golangci-lint run
4242
sources:
4343
- "{{.GO_SOURCES}}"
4444
- ".golangci.yml"
4545

4646
format:
4747
desc: Format code
48-
cmds:
49-
- go install mvdan.cc/gofumpt@latest
50-
- gofumpt -w .
48+
cmd: golangci-lint fmt
5149
sources:
5250
- "{{.GO_SOURCES}}"
51+
- ".golangci.yml"
5352

5453
test:
5554
desc: Run tests

cmd/root/catalog.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
"text/tabwriter"
1111
"time"
1212

13-
"github.com/docker/cagent/pkg/telemetry"
1413
"github.com/spf13/cobra"
14+
15+
"github.com/docker/cagent/pkg/telemetry"
1516
)
1617

1718
// NewCatalogCmd creates the catalog command with its subcommands

cmd/root/debug.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package root
33
import (
44
"log/slog"
55

6-
"github.com/docker/cagent/pkg/teamloader"
76
"github.com/spf13/cobra"
7+
8+
"github.com/docker/cagent/pkg/teamloader"
89
)
910

1011
// NewDebugCmd creates a command that prints the debug information about cagent.

cmd/root/feedback.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package root
33
import (
44
"fmt"
55

6-
"github.com/docker/cagent/pkg/telemetry"
76
"github.com/spf13/cobra"
7+
8+
"github.com/docker/cagent/pkg/telemetry"
89
)
910

1011
var FeedbackLink = "https://docker.qualtrics.com/jfe/form/SV_cNsCIg92nQemlfw"

cmd/root/gateway_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package root
33
import (
44
"testing"
55

6-
"github.com/docker/cagent/pkg/config"
76
"github.com/spf13/cobra"
87
"github.com/stretchr/testify/assert"
98
"github.com/stretchr/testify/require"
9+
10+
"github.com/docker/cagent/pkg/config"
1011
)
1112

1213
func TestGatewayLogic(t *testing.T) {

cmd/root/pull.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"path/filepath"
88
"strings"
99

10-
"github.com/docker/cagent/pkg/remote"
11-
"github.com/docker/cagent/pkg/telemetry"
1210
"github.com/google/go-containerregistry/pkg/crane"
1311
"github.com/spf13/cobra"
12+
13+
"github.com/docker/cagent/pkg/remote"
14+
"github.com/docker/cagent/pkg/telemetry"
1415
)
1516

1617
func NewPullCmd() *cobra.Command {

cmd/root/push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"fmt"
55
"log/slog"
66

7+
"github.com/google/go-containerregistry/pkg/crane"
8+
"github.com/spf13/cobra"
9+
710
"github.com/docker/cagent/pkg/content"
811
"github.com/docker/cagent/pkg/oci"
912
"github.com/docker/cagent/pkg/remote"
1013
"github.com/docker/cagent/pkg/telemetry"
11-
"github.com/google/go-containerregistry/pkg/crane"
12-
"github.com/spf13/cobra"
1314
)
1415

1516
func NewPushCmd() *cobra.Command {

cmd/root/readme.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"fmt"
55
"os"
66

7+
"github.com/spf13/cobra"
8+
79
"github.com/docker/cagent/pkg/config"
810
"github.com/docker/cagent/pkg/telemetry"
9-
"github.com/spf13/cobra"
1011
)
1112

1213
// NewReadmeCmd creates a command that prints the README of an agent.

cmd/root/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import (
99
"path/filepath"
1010
"strings"
1111

12+
"github.com/spf13/cobra"
13+
1214
"github.com/docker/cagent/pkg/environment"
1315
"github.com/docker/cagent/pkg/paths"
1416
"github.com/docker/cagent/pkg/telemetry"
1517
"github.com/docker/cagent/pkg/version"
16-
"github.com/spf13/cobra"
1718
)
1819

1920
var (

0 commit comments

Comments
 (0)