Skip to content

chore: simplify, modernize (Go 1.26), update deps#84

Open
rustatian wants to merge 2 commits into
masterfrom
chore/cleanup-modernize-deps
Open

chore: simplify, modernize (Go 1.26), update deps#84
rustatian wants to merge 2 commits into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian
Copy link
Copy Markdown
Member

Applied fixes

Bug fixes (R)

  • plugin.go:90 — Mutex was left locked when CreateListener fails; Stop would deadlock. Fixed by calling p.Unlock() on the error path before returning.
  • plugin.go:117Stop called app.Shutdown() which ignores the passed ctx deadline. Replaced with app.ShutdownWithContext(ctx).
  • plugin.go:36Config.Valid() was defined but never called in Init; invalid config (empty address, missing serve entries) would silently produce a broken server. Now called after UnmarshalKey.
  • plugin.go:99err = p.app.Listener(ln) reused the outer err via closure; replaced with := scoped to the goroutine.

Simplify (S)

  • plugin.go:57 — Removed 7 explicit zero-value fields from fiber.Config (noise).
  • plugin.go:80 — Index range over []*Cfg replaced with range-over-value.
  • plugin.go:110 — Merged endCh + errCh into a single chan error in Stop.
  • config.go:44 — Index range over []*Cfg replaced with range-over-value.

Modern Go (M)

  • plugin.go:80, config.go:44 — Go 1.22 range-over-element (same as S items above).

Not applied (needs manual review)

None — all 10 findings were applied.

Deps

go get -u all && go mod tidy — all dependencies were already at latest; no version changes in go.mod.

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • golangci-lint run — 0 issues

- Fix mutex left locked when CreateListener fails in Serve (deadlock on Stop)
- Use ShutdownWithContext(ctx) in Stop so the shutdown respects caller deadline
- Call Config.Valid() in Init to surface misconfiguration early
- Use := for inner err in Serve goroutine to avoid closing over the outer var
- Merge endCh+errCh into a single chan error in Stop
- Remove 7 explicit zero-value fields from fiber.Config (noise)
- Use range-over-value (Go 1.22) in Serve and Config.Valid
Copilot AI review requested due to automatic review settings May 29, 2026 12:20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@rustatian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1e8cd2e-3638-4ff4-8be4-012c76a2c6f9

📥 Commits

Reviewing files that changed from the base of the PR and between dfd6df5 and 7d84743.

📒 Files selected for processing (2)
  • config.go
  • plugin.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-modernize-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (dfd6df5) to head (7d84743).

Files with missing lines Patch % Lines
plugin.go 0.00% 21 Missing ⚠️
config.go 0.00% 8 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master     #84   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           2       2           
  Lines          88      76   -12     
======================================
+ Misses         88      76   -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 modernizes and simplifies the fileserver plugin while addressing shutdown and configuration validation behavior.

Changes:

  • Calls Config.Valid() during plugin initialization.
  • Simplifies Fiber config setup and static route iteration.
  • Updates shutdown handling to use ShutdownWithContext(ctx) and consolidates stop channels.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
plugin.go Adds config validation, simplifies Fiber setup, fixes listener error unlock path, and updates shutdown handling.
config.go Simplifies iteration over serve configurations while preserving default value assignment.

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

Comment thread config.go
The nil check passed an explicitly empty serve: [] slice, allowing
Init to accept a fileserver config with no routes despite the schema
requiring minItems: 1. Use len() to cover both nil and empty slices.
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