gin icon indicating copy to clipboard operation
gin copied to clipboard

fix(tree): Keep panic infos consistent when wildcard type build faild

Open kingcanfish opened this issue 1 year ago • 1 comments

fix(tree): Keep panic infos consistent when wildcard type build faild

When I run the demo1

// demo1
func main() {
	router := gin.Default()
	router.GET("/abc/bar", nil)
	router.GET("/abc/x*z", nil)

	router.Run("localhost:8080")
}

it got the panic:panic: no / before catch-all in path '/abc/x*z'

but when i run the demo2

// demo2
func main() {
	router := gin.Default()
	router.GET("/abc/bar", nil)
	router.GET("/abc/b*r", nil)

	router.Run("localhost:8080")
} 

it got the panic: panic: runtime error: index out of range [-1] Although the end result is the same(panic), the different panic informations may cause some confusion.

So, add the i < 0 condition to keep the panic infos same

kingcanfish avatar Oct 17 '24 07:10 kingcanfish

https://github.com/gin-gonic/gin/pull/4066 This PR fixed the ci-lint faild code

kingcanfish avatar Oct 17 '24 07:10 kingcanfish

build failed

appleboy avatar Oct 25 '24 01:10 appleboy

waiting for https://github.com/gin-gonic/gin/pull/4081

appleboy avatar Oct 25 '24 01:10 appleboy

please update the branch to the latest version.

appleboy avatar Oct 25 '24 01:10 appleboy

please update the branch to the latest version.

thank you for your review. I have updated to the latest version, but the golangci-lint still fails.

in my machine, golangci-lint (v1.60.2) is success, the same version as on github(v1.58.1) failed to run, so may be we need update the lint to the latest version?

kingcanfish avatar Oct 25 '24 02:10 kingcanfish

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.96%. Comparing base (3dc1cd6) to head (26f5476). Report is 78 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4077      +/-   ##
==========================================
- Coverage   99.21%   98.96%   -0.25%     
==========================================
  Files          42       44       +2     
  Lines        3182     3478     +296     
==========================================
+ Hits         3157     3442     +285     
- Misses         17       25       +8     
- Partials        8       11       +3     
Flag Coverage Δ
?
-tags "sonic avx" 98.95% <100.00%> (?)
-tags go_json 98.95% <100.00%> (?)
-tags nomsgpack 98.95% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 98.96% <100.00%> (-0.25%) :arrow_down:
go-1.22 98.96% <100.00%> (?)
macos-latest 98.96% <100.00%> (-0.25%) :arrow_down:
ubuntu-latest 98.96% <100.00%> (-0.25%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 25 '24 05:10 codecov[bot]

please update the branch to the latest version.

thank you for your review. I have updated to the latest version, but the golangci-lint still fails.

in my machine, golangci-lint (v1.60.2) is success, the same version as on github(v1.58.1) failed to run, so may be we need update the lint to the latest version?

update the golangci-lint to v1.62.0 :)

kingcanfish avatar Oct 25 '24 05:10 kingcanfish

@kingcanfish Thanks.

appleboy avatar Oct 26 '24 00:10 appleboy