Skip to content

Commit 848e1cd

Browse files
authored
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 <[email protected]>
1 parent c8af82a commit 848e1cd

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ formatters:
7272
- gofmt
7373
- gofumpt
7474
- goimports
75+
settings:
76+
gofmt:
77+
rewrite-rules:
78+
- pattern: 'interface{}'
79+
replacement: 'any'
7580
exclusions:
7681
generated: lax
7782
paths:

binding/plain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (plainBinding) Name() string {
1515
return "plain"
1616
}
1717

18-
func (plainBinding) Bind(req *http.Request, obj interface{}) error {
18+
func (plainBinding) Bind(req *http.Request, obj any) error {
1919
all, err := io.ReadAll(req.Body)
2020
if err != nil {
2121
return err

debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func IsDebugging() bool {
2525
var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
2626

2727
// DebugPrintFunc indicates debug log output format.
28-
var DebugPrintFunc func(format string, values ...interface{})
28+
var DebugPrintFunc func(format string, values ...any)
2929

3030
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
3131
if IsDebugging() {

render/render_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func TestRenderReaderNoContentLength(t *testing.T) {
608608
}
609609

610610
func TestRenderWriteError(t *testing.T) {
611-
data := []interface{}{"value1", "value2"}
611+
data := []any{"value1", "value2"}
612612
prefix := "my-prefix:"
613613
r := SecureJSON{Data: data, Prefix: prefix}
614614
ew := &errorWriter{

0 commit comments

Comments
 (0)