Skip to content

Comments

refactor: modernize codebase with idiomatic Go patterns and linter updates#6

Merged
appleboy merged 1 commit intomainfrom
lint
Feb 24, 2026
Merged

refactor: modernize codebase with idiomatic Go patterns and linter updates#6
appleboy merged 1 commit intomainfrom
lint

Conversation

@appleboy
Copy link
Member

  • Update linter configuration with new linters and settings, and remove deprecated ones
  • Add detailed linter rules and formatter settings to the configuration
  • Change error creation from fmt.Errorf to errors.New throughout the codebase
  • Replace map[string]interface{} with map[string]any for improved type clarity
  • Replace for loops of the form for i := 0; i < n; i++ with for i := range n for better idiomatic Go
  • Simplify timer and polling interval calculations using min/max functions
  • Use strconv.Itoa instead of fmt.Sprintf for integer to string conversion
  • Use t.Setenv in tests to manage environment variables instead of os.Setenv
  • Remove manual environment restoration in tests for improved reliability
  • Concatenate strings directly instead of using fmt.Sprintf where possible
  • Minor improvements to test comments for clarity

…dates

- Update linter configuration with new linters and settings, and remove deprecated ones
- Add detailed linter rules and formatter settings to the configuration
- Change error creation from fmt.Errorf to errors.New throughout the codebase
- Replace map[string]interface{} with map[string]any for improved type clarity
- Replace for loops of the form for i := 0; i < n; i++ with for i := range n for better idiomatic Go
- Simplify timer and polling interval calculations using min/max functions
- Use strconv.Itoa instead of fmt.Sprintf for integer to string conversion
- Use t.Setenv in tests to manage environment variables instead of os.Setenv
- Remove manual environment restoration in tests for improved reliability
- Concatenate strings directly instead of using fmt.Sprintf where possible
- Minor improvements to test comments for clarity

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings February 24, 2026 09:10
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 modernizes the codebase to follow idiomatic Go patterns and updates the linter configuration with new rules. The changes include replacing verbose constructs with cleaner alternatives introduced in recent Go versions, improving error handling consistency, and enhancing test reliability through better environment variable management.

Changes:

  • Updated linter configuration with modern linters and removed deprecated ones, adding detailed rules and formatter settings
  • Replaced fmt.Errorf with errors.New for static error messages throughout the codebase
  • Replaced map[string]interface{} with map[string]any for improved type clarity
  • Modernized for loops using Go 1.22+ range-over-integer syntax
  • Simplified timer and polling calculations using min/max functions
  • Used strconv.Itoa instead of fmt.Sprintf for integer-to-string conversion
  • Improved test reliability by using t.Setenv instead of manual environment variable management
  • Enhanced code clarity with direct string concatenation
  • Added explanatory comments to nolint directives

Reviewed changes

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

Show a summary per file
File Description
.golangci.yml Added modern linters (modernize, perfsprint, testifylint, etc.), removed deprecated ones, and added detailed configuration for linter rules and formatters
Makefile Added unset GOROOT && before golangci-lint run to avoid environment conflicts
userinfo.go Replaced fmt.Errorf with errors.New for static error message
tokens.go Replaced fmt.Errorf with errors.New for static error messages and error variable declarations
device_flow.go Replaced fmt.Errorf with errors.New for static errors, replaced map[string]interface{} with map[string]any, and used min for polling interval calculation
config.go Replaced fmt.Errorf with errors.New for validation errors and used strconv.Itoa for integer conversion
callback.go Replaced fmt.Errorf with errors.New for error variable declaration
callback_test.go Replaced fmt.Errorf with errors.New for static errors and added explanatory nolint comments
tui/messages.go Replaced map[string]interface{} with map[string]any
tui/manager.go Replaced interface{} with any
tui/manager_test.go Used t.Setenv instead of manual environment variable management and replaced map[string]interface{} with map[string]any
tui/device_view.go Used direct string concatenation instead of fmt.Sprintf
tui/device_model.go Used direct string concatenation instead of fmt.Sprintf
tui/browser_view.go Used direct string concatenation instead of fmt.Sprintf
tui/components/timer.go Used max function for cleaner countdown calculation and direct string concatenation
polling_test.go Replaced map[string]interface{} with map[string]any
main_test.go Replaced map[string]interface{} with map[string]any, modernized for loops using range syntax, and added explanatory nolint comment
pkce_test.go Modernized for loops using Go 1.22+ range-over-integer syntax
filelock_test.go Modernized for loop using range syntax
filelock.go Modernized for loop using range syntax when loop variable is unused
browser_flow.go Replaced map[string]interface{} with map[string]any

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

@appleboy appleboy merged commit ec35e13 into main Feb 24, 2026
20 checks passed
@appleboy appleboy deleted the lint branch February 24, 2026 10:40
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.

1 participant