chore: simplify + modernize (Go 1.26)#119
Conversation
Review findings: - resolveIP XFF: replace strings.Index + dead `len(fwd)<s` guard with strings.Cut - Middleware: range-over-value instead of index loop over p.trusted - drop unused exported Cidrs type (and now-unused net import) from config.go - move test-only inc() helper into trusted_test.go - collapse single-entry var() block Deps already current (go get -u all + go work sync were no-ops).
📝 WalkthroughWalkthroughThis PR refactors the proxy IP parser package by removing the exported ChangesCore Refactoring and API Cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Cleanup pass on the proxy_ip_parser RoadRunner middleware: removes dead/unreachable code, modernizes a loop, and tidies declarations. No behavior changes intended.
Changes:
- Simplify XFF parsing in
resolveIPusingstrings.Cut, eliminating an unreachablelen(fwd) < sguard. - Use range-over-value in the trusted-subnet loop; collapse the single-entry
var()block. - Remove the unused exported
Cidrstype (andnetimport) fromconfig.go; move the test-onlyinc()helper intotrusted_test.go.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| plugin.go | Simplify XFF branch with strings.Cut; range-over-value loop; collapse var block; drop inc() helper. |
| trusted_test.go | Host the test-only inc() helper now removed from plugin.go. |
| config.go | Drop unused Cidrs type and net import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cleanup pass from a multi-plugin review (
/simplify+/use-modern-goGo 1.26 +/review).Changes
resolveIPXFF branch had a dead, inverted guardif len(fwd) < s(unreachable —strings.Indexalready returneds >= 0). Replaced the wholeIndex+slice dance withstrings.Cut, which returns the full string when no comma is present.for _, subnet := range p.trusted) instead of index loop.Cidrstype (and its now-unusednetimport) fromconfig.go.inc()helper intotrusted_test.go; collapsed a single-entryvar()block.Deps
go get -u all(root + tests) andgo work syncwere no-ops — module already current.Summary by CodeRabbit
Refactor
Tests