Skip to content

Fix ShouldBindBodyWith docs example using binding.Form - #4766

Open
Hashim1999164 wants to merge 1 commit into
gin-gonic:masterfrom
Hashim1999164:fix/should-bind-body-with-form-docs
Open

Fix ShouldBindBodyWith docs example using binding.Form#4766
Hashim1999164 wants to merge 1 commit into
gin-gonic:masterfrom
Hashim1999164:fix/should-bind-body-with-form-docs

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • The ShouldBindBodyWith example in docs/doc.md used binding.Form, which does not implement BindingBody, so that call is invalid.
  • Updated the example to use binding.JSON, which matches the supported body binders listed in the same section.

Fixes #3296

Test plan

  • Confirm the example in docs/doc.md compiles conceptually against ShouldBindBodyWith / BindingBody
  • Skim the surrounding docs note that Form should use ShouldBind instead of ShouldBindBodyWith

binding.Form does not implement BindingBody, so the docs example
could not compile or run. Use binding.JSON instead.

Fixes gin-gonic#3296
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.32%. Comparing base (3dc1cd6) to head (909b6f3).
⚠️ Report is 289 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4766      +/-   ##
==========================================
- Coverage   99.21%   98.32%   -0.89%     
==========================================
  Files          42       48       +6     
  Lines        3182     3172      -10     
==========================================
- Hits         3157     3119      -38     
- Misses         17       43      +26     
- Partials        8       10       +2     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.31% <ø> (?)
-tags go_json 98.25% <ø> (?)
-tags nomsgpack 98.30% <ø> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.25 98.32% <ø> (?)
go-1.26 98.32% <ø> (?)
macos-latest 98.32% <ø> (-0.89%) ⬇️
ubuntu-latest 98.32% <ø> (-0.89%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

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.

README.md error errA := c.ShouldBindBodyWith(&objA, binding.Form)

1 participant