Skip to content

refactor: apply code style and linter improvements across Go files#3

Merged
appleboy merged 1 commit into
mainfrom
lint
Feb 27, 2026
Merged

refactor: apply code style and linter improvements across Go files#3
appleboy merged 1 commit into
mainfrom
lint

Conversation

@appleboy
Copy link
Copy Markdown
Member

  • Refactor file locking parameters into top-level constants in filelock.go for improved maintainability.
  • Replace duplicated error handling durations and retry settings with reusable constants in file locking logic.
  • Update for-loops to use range-based iteration on integer variables for better Go style in tests and concurrency code.
  • Replace usage of fmt.Errorf with errors.New for static error strings.
  • Prefer named http.Method* constants over string literals for HTTP methods in main.go and tests.
  • Use map[string]any instead of map[string]interface{} for type declarations.
  • Add and fine-tune multiple linters and their configurations in .golangci.yml; introduce new linter settings and rules, improve output formatting, and remove several linters no longer used.
  • Update comments or linter ignore statements for greater clarity.
  • Use a min() helper rather than manual interval capping in polling logic.

- Refactor file locking parameters into top-level constants in filelock.go for improved maintainability.
- Replace duplicated error handling durations and retry settings with reusable constants in file locking logic.
- Update for-loops to use range-based iteration on integer variables for better Go style in tests and concurrency code.
- Replace usage of fmt.Errorf with errors.New for static error strings.
- Prefer named http.Method* constants over string literals for HTTP methods in main.go and tests.
- Use map[string]any instead of map[string]interface{} for type declarations.
- Add and fine-tune multiple linters and their configurations in .golangci.yml; introduce new linter settings and rules, improve output formatting, and remove several linters no longer used.
- Update comments or linter ignore statements for greater clarity.
- Use a min() helper rather than manual interval capping in polling logic.

Signed-off-by: appleboy <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings February 27, 2026 12:29
Copy link
Copy Markdown

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 applies comprehensive code style and linter improvements across the Go codebase, modernizing the code to use Go 1.22+ features and enforcing consistent patterns through enhanced linter configuration.

Changes:

  • Extracted magic numbers and durations in file locking logic into top-level constants for better maintainability
  • Replaced fmt.Errorf with errors.New for static error strings to improve efficiency and semantic clarity
  • Updated HTTP method calls to use named http.Method* constants instead of string literals
  • Modernized for-loops to use Go 1.22+ range-based iteration over integers
  • Replaced map[string]interface{} with map[string]any throughout test files
  • Replaced manual interval capping logic with the builtin min() helper function
  • Enhanced .golangci.yml with additional linters (modernize, usestdlibvars, revive, etc.) and stricter nolint requirements
  • Added explanation to nolint directive for improved documentation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
filelock.go Extracted lock retry and timeout parameters into top-level constants; converted loop to use range-based iteration
main.go Replaced fmt.Errorf with errors.New for static strings; updated HTTP methods to use constants; simplified interval capping with min()
main_test.go Replaced map[string]interface{} with map[string]any; converted loops to range-based iteration; added explanation to nolint comment
polling_test.go Replaced map[string]interface{} with map[string]any; updated HTTP method check to use constant
filelock_test.go Converted loop to use range-based iteration
.golangci.yml Added multiple linters (bidichk, modernize, usestdlibvars, revive, etc.); configured stricter nolint rules requiring explanations; removed unused linters; added timeout configuration

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

@appleboy appleboy merged commit 5659b5b into main Feb 27, 2026
20 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