* refactor(context): refactor keys to `map[any]any`
Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
* refactor(context): refactor keys to `map[any]any`
Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
* style(context): remove empty lines before GetInt16, GetIntSlice, and GetStringMapString methods
- Remove unnecessary empty lines in the context.go file
- Improve code readability and consistency
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
* refactor(context): simplify GetStringSlice function
- Replace manual type assertion with generic getTyped function
- Reduce code duplication and improve type safety
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
* test(context): improve context.Set and context.Get tests
- Split existing test into separate functions for different scenarios
- Add test for setting and getting values with any key type
- Add test for handling non-comparable keys
- Improve assertions to check for key existence and value correctness
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
* refactor(context): replace fmt.Errorf with fmt.Sprintf in panic message
* test(context): remove trailing hyphen from context_test.go
* refactor(context): improve error message for missing key in context
- Remove unnecessary quotes around the key in the error message
- Simplify the error message format for better readability
* test(context): improve panic test message for non-existent key
---------
Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
- Update golangci.yml to use 'any' instead of 'interface{}' in gofmt
- Modify debug.go, plain.go, and render_test.go to use 'any' type
- Improve code readability and follow modern Go conventions
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* Bind: return 413 status code when error is `http.MaxBytesError`
The Go standard library includes a method `http.MaxBytesReader` that allows limiting the request body. For example, users can create a middleware like:
```go
func MiddlewareMaxBodySize(c *gin.Context) {
// Limit request body to 100 bytes
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 100)
c.Next()
}
```
When the body exceeds the limit, reading from the request body returns an error of type `http.MaxBytesError`.
This PR makes sure that when the error is of kind `http.MaxBytesError`, Gin returns the correct status code 413 (Request Entity Too Large) instead of a generic 400 (Bad Request).
* Disable test when using sonic
* Fix
* Disable for go-json too
* Add references to GitHub issues
* Test that the response is 400 for sonic and go-json
* ci: update golangci-lint configuration and lint settings
- Update golangci-lint to version 2
- Enable new linters and adjust existing ones
- Update lint settings across multiple test files
- Remove unused struct and variable checks
- Add new lint exclusions for generated code and specific directories
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* ci(github): update golangci-lint-action to v8 and lint version to v2.3.4
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* ci: downgrade golangci-lint to v2.1.6
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* ci(golangci): add gofumpt linter and fix related issues- Added gofumpt linter to .golangci.yml
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* test: ignore testifylint and gofumpt lints in specific test cases
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
* build(deps): remove golang.org/x/lint
- Remove golang.org/x/lint package from go.mod
- Update related dependencies in go.sum
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
* build(deps): downgrade golang.org/x/mod and golang.org/x/tools
- Downgrade golang.org/x/mod from v0.24.0 to v0.18.0
- Downgrade golang.org/x/tools from v0.33.0 to v.22.0
These changes are made to address compatibility issues with the current project setup.
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
---------
Signed-off-by: Flc <four_leaf_clover@foxmail.com>
Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
* chore: update Go versions and dependencies for improved compatibility
- Update Go versions in workflow file to `1.23` and `1.24`
- Enhance test tags in workflow with specific linker flags
- Remove the conditional formatting step for Go `1.22.x` in workflow
- Remove `goimports` settings from `.golangci.yml`
- Update `go.mod` to use Go `1.23.0`
- Upgrade `github.com/bytedance/sonic` from `v1.11.6` to `v1.13.1`
- Update indirect dependencies `sonic/loader` to `v0.2.4` and `base64x` to `v0.1.5` in `go.mod`
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: update project for Go 1.23 compatibility and documentation fixes
- Update Go version requirement from 1.22 to 1.23 in README.md
- Remove superfluous `$` from example command in README.md
- Update warning message to reflect new Go version requirement in debug.go
- Update test assertion to reflect new Go version requirement in debug_test.go
Signed-off-by: appleboy <appleboy.tw@gmail.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Update Go versions in GitHub Actions workflow to `1.22` and `1.23`
- Update README to require Go version `1.22` or above
- Adjust table formatting in README for better alignment
- Update warning message in `debug.go` to reflect Go version `1.22`
- Update test in `debug_test.go` to reflect Go version `1.22`
- Update `go.mod` to require Go version `1.22`
- Update dependencies in `go.mod` to newer versions
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Update GoReleaser action to version 6 in GitHub workflow
- Use `http.MethodPost` constant in test requests instead of hardcoded string
Signed-off-by: appleboy <appleboy.tw@gmail.com>