Skip to content

Comments

Simplify bodyWriter write method using io.Copy#76

Merged
samber merged 2 commits intomainfrom
fix-simplify-copy-hack
Feb 6, 2026
Merged

Simplify bodyWriter write method using io.Copy#76
samber merged 2 commits intomainfrom
fix-simplify-copy-hack

Conversation

@samber
Copy link
Owner

@samber samber commented Feb 6, 2026

Refactor write handling in bodyWriter to use io.Copy for simplicity.

poke @schnoddelbotz

Refactor write handling in bodyWriter to use io.Copy for simplicity.
Copilot AI review requested due to automatic review settings February 6, 2026 17:17
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (d098e39) to head (67f8f4e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dump.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main     #76   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          4       4           
  Lines        404     372   -32     
=====================================
+ Misses       404     372   -32     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@samber samber merged commit 2e0bde9 into main Feb 6, 2026
13 checks passed
@samber samber deleted the fix-simplify-copy-hack branch February 6, 2026 17:19
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

Refactors bodyWriter.ReadFrom in dump.go to rely on io.Copy instead of maintaining a custom copy loop, simplifying response body capture while preserving the ability to delegate to the underlying gin.ResponseWriter when possible.

Changes:

  • Removed the custom buffered copy loop and replaced it with io.Copy (with a wrapper to avoid io.ReaderFrom recursion).
  • Deleted the now-unneeded errInvalidWrite error value.
Comments suppressed due to low confidence (1)

dump.go:19

  • After removing errInvalidWrite, the errors import in this file becomes unused, which will cause the package to fail to compile. Please remove the errors import (or reintroduce a use if needed).
	gin.ResponseWriter
	body    *bytes.Buffer
	maxSize int

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

break
}
}

Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

io.Copy(struct{ io.Writer }{w}, r) intentionally wraps w to hide the io.ReaderFrom method (otherwise io.Copy would dispatch back to ReadFrom and recurse). Please add a short comment or use a named wrapper type to make this non-obvious requirement clearer and prevent accidental simplification to io.Copy(w, r) later.

Suggested change
// Wrap w to hide its ReadFrom method and avoid infinite recursion via io.Copy.

Copilot uses AI. Check for mistakes.
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