mirror of
https://github.com/gin-gonic/gin.git
synced 2025-08-07 11:49:48 +08:00
refactor: replace interface{} with any in type declarations (#4249)
- 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>
This commit is contained in:
parent
c8af82af15
commit
848e1cdd0d
@ -72,6 +72,11 @@ formatters:
|
|||||||
- gofmt
|
- gofmt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- goimports
|
- goimports
|
||||||
|
settings:
|
||||||
|
gofmt:
|
||||||
|
rewrite-rules:
|
||||||
|
- pattern: 'interface{}'
|
||||||
|
replacement: 'any'
|
||||||
exclusions:
|
exclusions:
|
||||||
generated: lax
|
generated: lax
|
||||||
paths:
|
paths:
|
||||||
|
@ -15,7 +15,7 @@ func (plainBinding) Name() string {
|
|||||||
return "plain"
|
return "plain"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plainBinding) Bind(req *http.Request, obj interface{}) error {
|
func (plainBinding) Bind(req *http.Request, obj any) error {
|
||||||
all, err := io.ReadAll(req.Body)
|
all, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
2
debug.go
2
debug.go
@ -25,7 +25,7 @@ func IsDebugging() bool {
|
|||||||
var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
|
var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
|
||||||
|
|
||||||
// DebugPrintFunc indicates debug log output format.
|
// DebugPrintFunc indicates debug log output format.
|
||||||
var DebugPrintFunc func(format string, values ...interface{})
|
var DebugPrintFunc func(format string, values ...any)
|
||||||
|
|
||||||
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
||||||
if IsDebugging() {
|
if IsDebugging() {
|
||||||
|
@ -608,7 +608,7 @@ func TestRenderReaderNoContentLength(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRenderWriteError(t *testing.T) {
|
func TestRenderWriteError(t *testing.T) {
|
||||||
data := []interface{}{"value1", "value2"}
|
data := []any{"value1", "value2"}
|
||||||
prefix := "my-prefix:"
|
prefix := "my-prefix:"
|
||||||
r := SecureJSON{Data: data, Prefix: prefix}
|
r := SecureJSON{Data: data, Prefix: prefix}
|
||||||
ew := &errorWriter{
|
ew := &errorWriter{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user