Skip to content

docs: add panic conditions documentation for Handle, StaticFS, and Bind#4607

Open
xingzihai wants to merge 1 commit intogin-gonic:masterfrom
xingzihai:docs-panic-conditions
Open

docs: add panic conditions documentation for Handle, StaticFS, and Bind#4607
xingzihai wants to merge 1 commit intogin-gonic:masterfrom
xingzihai:docs-panic-conditions

Conversation

@xingzihai
Copy link
Copy Markdown

Summary

This PR adds documentation for panic conditions in three exported functions:

  • Handle: panics if httpMethod is not a valid HTTP method (uppercase ASCII letters only)
  • StaticFS: panics if relativePath contains URL parameters (: or *)
  • Bind: panics if val is a pointer

Motivation

Three exported public API functions contain panic() calls on invalid input, but none of the doc comments mention the panic conditions. Callers cannot discover the crash risk without reading the source. This is a documentation gap — the panics themselves are reasonable startup-time guards, but they should be documented.

Changes

Added panic condition documentation to each function's doc comment:

  1. RouterGroup.Handle in routergroup.go
  2. RouterGroup.StaticFS in routergroup.go
  3. Bind in utils.go

Related Issue

Fixes #4594

Testing

This is a documentation-only change. No functional code changes were made.

  • Documentation builds correctly
  • No test changes needed (documentation only)

Checklist

  • Documentation added/updated
  • Commit message follows conventional commits
  • PR title clearly describes the change

This commit adds documentation for panic conditions in three exported functions:

- Handle: panics if httpMethod is not a valid HTTP method (uppercase ASCII letters only)
- StaticFS: panics if relativePath contains URL parameters (: or *)
- Bind: panics if val is a pointer

Fixes gin-gonic#4594
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.37%. Comparing base (3dc1cd6) to head (8f92e31).
⚠️ Report is 275 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4607      +/-   ##
==========================================
- Coverage   99.21%   98.37%   -0.84%     
==========================================
  Files          42       48       +6     
  Lines        3182     3138      -44     
==========================================
- Hits         3157     3087      -70     
- Misses         17       42      +25     
- Partials        8        9       +1     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.36% <ø> (?)
-tags go_json 98.29% <ø> (?)
-tags nomsgpack 98.35% <ø> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.25 98.37% <ø> (?)
go-1.26 98.37% <ø> (?)
macos-latest 98.37% <ø> (-0.84%) ⬇️
ubuntu-latest 98.37% <ø> (-0.84%) ⬇️

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.

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.

Undocumented panic behavior in Handle, StaticFS, and Bind

1 participant