From 1326df816b55c8f42e3c3155895b8f9d3e9ee861 Mon Sep 17 00:00:00 2001 From: OpenWaygate <27287694+OpenWaygate@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:36:15 +0800 Subject: [PATCH] :chore: Refactor codes and upgrade golangci-lint in ci --- .github/workflows/test.yml | 2 +- AGENTS.md | 2 +- internal/tools/cmdtestgen/main.go | 36 ++++++++++++++++++------------- pkg/utils/utils_test.go | 3 ++- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4016b7a..5c538f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v9 with: - version: v2.12 + version: latest - name: Go test run: | go test ./... -coverprofile=${{ env.COVERAGE_FILE }} -coverpkg="./pkg/..." diff --git a/AGENTS.md b/AGENTS.md index eb67cd7..287316f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,7 +17,7 @@ Go CLI + MCP server + Agent for YouTube. | [pkg/](pkg/AGENTS.md) | Core domain logic and shared infrastructure | | [internal/](internal/AGENTS.md) | Internal tools (docgen, skillgen) | | [scripts/](scripts/AGENTS.md) | Utility scripts and smoke tests | -| [docs/](docs/) | Project documentation | +| [docs/](docs) | Project documentation | ## Documentation diff --git a/internal/tools/cmdtestgen/main.go b/internal/tools/cmdtestgen/main.go index efc6c28..5f3a254 100644 --- a/internal/tools/cmdtestgen/main.go +++ b/internal/tools/cmdtestgen/main.go @@ -118,25 +118,29 @@ func generate() string { } } - slices.SortFunc(coreCommands, func(a, b *cobra.Command) int { - return cmp.Compare(a.Name(), b.Name()) - }) - slices.SortFunc(resourceCommands, func(a, b *cobra.Command) int { - return cmp.Compare(a.Name(), b.Name()) - }) + slices.SortFunc( + coreCommands, func(a, b *cobra.Command) int { + return cmp.Compare(a.Name(), b.Name()) + }, + ) + slices.SortFunc( + resourceCommands, func(a, b *cobra.Command) int { + return cmp.Compare(a.Name(), b.Name()) + }, + ) b.WriteString("\n# yutu\n") for _, c := range coreCommands { name := c.Name() - fmt.Fprintf(&b, "echo \"======= %s =======\"\n", name) - fmt.Fprintf(&b, "\"$YUTU_PATH\" %s --help\n\n", name) + _, _ = fmt.Fprintf(&b, "echo \"======= %s =======\"\n", name) + _, _ = fmt.Fprintf(&b, "\"$YUTU_PATH\" %s --help\n\n", name) } b.WriteString("# youtube api\n") for _, c := range resourceCommands { name := c.Name() - fmt.Fprintf(&b, "echo \"======= %s =======\"\n", name) - fmt.Fprintf(&b, "\"$YUTU_PATH\" %s --help\n", name) + _, _ = fmt.Fprintf(&b, "echo \"======= %s =======\"\n", name) + _, _ = fmt.Fprintf(&b, "\"$YUTU_PATH\" %s --help\n", name) var subs []*cobra.Command for _, sub := range c.Commands() { @@ -145,13 +149,15 @@ func generate() string { } subs = append(subs, sub) } - slices.SortFunc(subs, func(a, b *cobra.Command) int { - return cmp.Compare(a.Name(), b.Name()) - }) + slices.SortFunc( + subs, func(a, b *cobra.Command) int { + return cmp.Compare(a.Name(), b.Name()) + }, + ) for _, sub := range subs { - fmt.Fprintf(&b, "echo \"------- %s -------\"\n", sub.Name()) - fmt.Fprintf(&b, "\"$YUTU_PATH\" %s %s --help\n", name, sub.Name()) + _, _ = fmt.Fprintf(&b, "echo \"------- %s -------\"\n", sub.Name()) + _, _ = fmt.Fprintf(&b, "\"$YUTU_PATH\" %s %s --help\n", name, sub.Name()) } b.WriteString("\n") } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index 33444cd..d532ff8 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -5,6 +5,7 @@ package utils import ( "bytes" + "errors" "fmt" "io" "os" @@ -468,7 +469,7 @@ func TestConfirmPreRun(t *testing.T) { cmd.SetIn(strings.NewReader(tt.input)) err := ConfirmPreRun(cmd, "Would do something") - if err != tt.wantErr { + if !errors.Is(err, tt.wantErr) { t.Errorf("ConfirmPreRun() error = %v, want %v", err, tt.wantErr) } },