Skip to content

Commit 62439a2

Browse files
authored
refactor: replace interface{} with any for clarity and modernization (#2829)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> Inspired by #2781 and replace all. This change replaces occurrences of interface{} with the predeclared identifier any, introduced in Go 1.18 as an alias for interface{}. As noted in the [Go 1.18 Release Notes](https://go.dev/doc/go1.18#language): This improves readability and aligns the codebase with modern Go conventions. Signed-off-by: promalert <promalert@outlook.com>
1 parent b3f734b commit 62439a2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

block/internal/submitting/da_submitter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,20 +364,20 @@ func mergeSubmitOptions(baseOptions []byte, signingAddress string) ([]byte, erro
364364
return baseOptions, nil
365365
}
366366

367-
var optionsMap map[string]interface{}
367+
var optionsMap map[string]any
368368

369369
// If base options are provided, try to parse them as JSON
370370
if len(baseOptions) > 0 {
371371
// Try to unmarshal existing options, ignoring errors for non-JSON input
372372
if err := json.Unmarshal(baseOptions, &optionsMap); err != nil {
373373
// Not valid JSON - start with empty map
374-
optionsMap = make(map[string]interface{})
374+
optionsMap = make(map[string]any)
375375
}
376376
}
377377

378378
// Ensure map is initialized even if unmarshal returned nil
379379
if optionsMap == nil {
380-
optionsMap = make(map[string]interface{})
380+
optionsMap = make(map[string]any)
381381
}
382382

383383
// Add or override the signing address

block/internal/submitting/da_submitter_options_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestMergeSubmitOptions_EmptyBaseOptions(t *testing.T) {
2222
result, err := mergeSubmitOptions([]byte{}, signingAddress)
2323
require.NoError(t, err)
2424

25-
var resultMap map[string]interface{}
25+
var resultMap map[string]any
2626
err = json.Unmarshal(result, &resultMap)
2727
require.NoError(t, err)
2828

@@ -36,7 +36,7 @@ func TestMergeSubmitOptions_ValidJSON(t *testing.T) {
3636
result, err := mergeSubmitOptions(baseOptions, signingAddress)
3737
require.NoError(t, err)
3838

39-
var resultMap map[string]interface{}
39+
var resultMap map[string]any
4040
err = json.Unmarshal(result, &resultMap)
4141
require.NoError(t, err)
4242

@@ -52,7 +52,7 @@ func TestMergeSubmitOptions_InvalidJSON(t *testing.T) {
5252
result, err := mergeSubmitOptions(baseOptions, signingAddress)
5353
require.NoError(t, err)
5454

55-
var resultMap map[string]interface{}
55+
var resultMap map[string]any
5656
err = json.Unmarshal(result, &resultMap)
5757
require.NoError(t, err)
5858

@@ -68,7 +68,7 @@ func TestMergeSubmitOptions_OverrideExistingAddress(t *testing.T) {
6868
result, err := mergeSubmitOptions(baseOptions, newAddress)
6969
require.NoError(t, err)
7070

71-
var resultMap map[string]interface{}
71+
var resultMap map[string]any
7272
err = json.Unmarshal(result, &resultMap)
7373
require.NoError(t, err)
7474

@@ -82,7 +82,7 @@ func TestMergeSubmitOptions_NilBaseOptions(t *testing.T) {
8282
result, err := mergeSubmitOptions(nil, signingAddress)
8383
require.NoError(t, err)
8484

85-
var resultMap map[string]interface{}
85+
var resultMap map[string]any
8686
err = json.Unmarshal(result, &resultMap)
8787
require.NoError(t, err)
8888

@@ -102,17 +102,17 @@ func TestMergeSubmitOptions_ComplexJSON(t *testing.T) {
102102
result, err := mergeSubmitOptions(baseOptions, signingAddress)
103103
require.NoError(t, err)
104104

105-
var resultMap map[string]interface{}
105+
var resultMap map[string]any
106106
err = json.Unmarshal(result, &resultMap)
107107
require.NoError(t, err)
108108

109109
// Check nested structure is preserved
110-
nested, ok := resultMap["nested"].(map[string]interface{})
110+
nested, ok := resultMap["nested"].(map[string]any)
111111
require.True(t, ok)
112112
assert.Equal(t, "value", nested["key"])
113113

114114
// Check array is preserved
115-
array, ok := resultMap["array"].([]interface{})
115+
array, ok := resultMap["array"].([]any)
116116
require.True(t, ok)
117117
assert.Len(t, array, 3)
118118

0 commit comments

Comments
 (0)