Skip to content

fix: prefer any vs interface{} #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ledger/alonzo/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func (g *AlonzoGenesis) NormalizeCostModels() error {
}

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

func toInt(v interface{}) (int, error) {
func toInt(v any) (int, error) {
switch val := v.(type) {
case float64:
if val > float64(math.MaxInt) || val < float64(math.MinInt) {
Expand Down
4 changes: 2 additions & 2 deletions ledger/alonzo/pparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestCostModelArrayFormat(t *testing.T) {
}

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

func toJSON(v interface{}) string {
func toJSON(v any) string {
b, err := json.Marshal(v)
if err != nil {
panic(fmt.Sprintf("failed to marshal JSON: %v", err))
Expand Down
Loading