Skip to content

fix(lint): resolve all 49 golangci-lint issues#262

Merged
appleboy merged 3 commits intomainfrom
fix/lint-issues
Mar 8, 2026
Merged

fix(lint): resolve all 49 golangci-lint issues#262
appleboy merged 3 commits intomainfrom
fix/lint-issues

Conversation

@appleboy
Copy link
Owner

@appleboy appleboy commented Mar 8, 2026

Summary

  • Upgrade .golangci.yml to v2 with stricter linters (modernize, perfsprint, usestdlibvars, usetesting, nilnil, forbidigo, depguard, revive)
  • Fix all 49 lint issues across 19 files: replace interface{} with any, use maps.Copy/strings.SplitSeq, use errors.New for static errors, use stdlib constants, use t.Chdir/t.Setenv in tests, add nolint explanations, replace fmt.Printf with proper error returns

Test plan

  • make lint passes with 0 issues
  • make test passes with all tests green

🤖 Generated with Claude Code

- Upgrade golangci-lint config to v2 with stricter linters
- Replace interface{} with any and use maps.Copy, strings.SplitSeq
- Use errors.New for static error strings instead of fmt.Errorf
- Use http.StatusOK and http.MethodGet stdlib constants in tests
- Replace os.Chdir/os.Setenv with t.Chdir/t.Setenv in tests
- Add required explanations to all nolint directives
- Replace fmt.Printf with proper error returns in anthropic provider

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 8, 2026 09:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the repository’s linting configuration to golangci-lint v2 with a stricter linter set, and applies code/test changes across the codebase to resolve the reported lint violations.

Changes:

  • Upgraded .golangci.yml to v2 and enabled additional linters with new settings/exclusions.
  • Modernized Go code to satisfy lint rules (e.g., any, maps.Copy, strings.SplitSeq, errors.New, stdlib constants).
  • Improved test hygiene by using t.Setenv/t.Chdir and adding nolint explanations where required.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
version/version.go Simplifies App var declaration to satisfy style/lint.
util/util_test.go Switches test setup to use t.Setenv and removes error-returning setup.
util/template_test.go Uses any + maps.Copy to populate template vars.
util/template.go Updates template data types and function signatures to any.
util/api_key_helper_unix.go Replaces static fmt.Errorf with errors.New for constant errors.
util/api_key_helper_test.go Uses t.Setenv and adjusts command construction in cache-expiration test.
util/api_key_helper.go Adds nilnil explanations and uses errors.New for static errors.
proxy/proxy.go Uses errors.New for static errors and improves nolint:gosec rationale formatting.
provider/openai/openai.go Uses errors.New for static “no choices” error.
provider/anthropic/anthropic.go Removes fmt.Printf and returns formatted errors instead.
prompt/prompt.go Adds explanation to nolint:gochecknoinits.
git/hook.go Adds explanation to nolint:gochecknoinits.
git/git_test.go Uses t.Chdir and simplifies error variable usage.
git/git.go Replaces fmt.Sprintf with concatenation and adds nolint:gosec explanation.
core/transport/transport_test.go Uses stdlib constants (http.StatusOK, http.MethodGet) and formats request creation.
cmd/version.go Changes output printing to use color.White.
cmd/textarea.go Uses strings.SplitSeq and adds explanation to nolint:exhaustive.
cmd/commit.go Uses maps.Copy when merging template vars into util.Data.
.golangci.yml Migrates to golangci-lint v2 config and enables/configures additional linters/formatters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

appleboy and others added 2 commits March 8, 2026 17:37
- Wrap original error with %w in anthropic APIError branches
- Add trailing newline to color.White version output
- Quote file path in test shell command with fmt.Sprintf %q

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use errors.New for static error strings in api_key_helper_windows.go
- Modernize for loops to range over int in windows test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@appleboy appleboy merged commit 5aa0e69 into main Mar 8, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants