Skip to content

Commit 71fe314

Browse files
authored
fix: prefer any vs interface{} (#1048)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent d6b7bec commit 71fe314

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

ledger/alonzo/genesis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ func (g *AlonzoGenesis) NormalizeCostModels() error {
6666
}
6767

6868
func (c *CostModel) UnmarshalJSON(data []byte) error {
69-
tmpMap := make(map[string]interface{})
69+
tmpMap := make(map[string]any)
7070
if err := json.Unmarshal(data, &tmpMap); err != nil {
7171
// Try to unmarshal as array first
72-
var tmpArray []interface{}
72+
var tmpArray []any
7373
if arrayErr := json.Unmarshal(data, &tmpArray); arrayErr == nil {
7474
*c = make(CostModel)
7575
for i, v := range tmpArray {
@@ -95,7 +95,7 @@ func (c *CostModel) UnmarshalJSON(data []byte) error {
9595
return nil
9696
}
9797

98-
func toInt(v interface{}) (int, error) {
98+
func toInt(v any) (int, error) {
9999
switch val := v.(type) {
100100
case float64:
101101
if val > float64(math.MaxInt) || val < float64(math.MinInt) {

ledger/alonzo/pparams_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func TestCostModelArrayFormat(t *testing.T) {
224224
}
225225

226226
func TestScientificNotationInCostModels(t *testing.T) {
227-
costModel := map[string]interface{}{
227+
costModel := map[string]any{
228228
"0": 2.477736e+06, // Changed from param1 to 0
229229
"1": 1.5e6, // Changed from param2 to 1
230230
"2": 1000000, // Changed from param3 to 2
@@ -442,7 +442,7 @@ func TestAlonzoUtxorpc(t *testing.T) {
442442
}
443443
}
444444

445-
func toJSON(v interface{}) string {
445+
func toJSON(v any) string {
446446
b, err := json.Marshal(v)
447447
if err != nil {
448448
panic(fmt.Sprintf("failed to marshal JSON: %v", err))

0 commit comments

Comments
 (0)