From fcc689453eb6d85cfff96fe653778a99a41e4534 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Thu, 12 Feb 2026 20:12:06 -1000 Subject: [PATCH] refactor: apply go fix modernizers from Go 1.26 This PR applies automated refactoring from go 1.26 (go fix ./...): - interface{} to any, slices.Contains, prefer range loops, and other idiomatic updates. --- pkg/adpub/ad_stats.go | 4 ++-- pkg/adpub/client_store.go | 4 ++-- pkg/spaddr/spinfo/spinfo.go | 2 +- pkg/spaddr/spinfo/spinfo_test.go | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/adpub/ad_stats.go b/pkg/adpub/ad_stats.go index d473100..84b5cea 100644 --- a/pkg/adpub/ad_stats.go +++ b/pkg/adpub/ad_stats.go @@ -20,8 +20,8 @@ type AdStats struct { ctxIDRm map[string]bool samples []*AdSample - mhCountDist []interface{} - chunkCountDist []interface{} + mhCountDist []any + chunkCountDist []any } type AdSample struct { diff --git a/pkg/adpub/client_store.go b/pkg/adpub/client_store.go index 7ffde7e..9d32d39 100644 --- a/pkg/adpub/client_store.go +++ b/pkg/adpub/client_store.go @@ -164,7 +164,7 @@ func (s *ClientStore) getAdvertisement(ctx context.Context, id cid.Cid) (*Advert } func (s *ClientStore) list(ctx context.Context, nextCid cid.Cid, n int, w io.Writer) error { - for i := 0; i < n; i++ { + for range n { ad, err := s.loadAd(ctx, nextCid) if err != nil { return err @@ -185,7 +185,7 @@ func (s *ClientStore) list(ctx context.Context, nextCid cid.Cid, n int, w io.Wri } func (s *ClientStore) crawl(ctx context.Context, nextCid cid.Cid, n int, ads chan<- *Advertisement) (cid.Cid, error) { - for i := 0; i < n; i++ { + for range n { ad, err := s.loadAd(ctx, nextCid) if err != nil { return cid.Undef, err diff --git a/pkg/spaddr/spinfo/spinfo.go b/pkg/spaddr/spinfo/spinfo.go index 34ac6f7..2c66bd7 100644 --- a/pkg/spaddr/spinfo/spinfo.go +++ b/pkg/spaddr/spinfo/spinfo.go @@ -17,7 +17,7 @@ type ExpTipSet struct { Cids []cid.Cid //Blocks []*BlockHeader //Height abi.ChainEpoch - Blocks []interface{} + Blocks []any Height int64 } diff --git a/pkg/spaddr/spinfo/spinfo_test.go b/pkg/spaddr/spinfo/spinfo_test.go index 1006b3c..925a415 100644 --- a/pkg/spaddr/spinfo/spinfo_test.go +++ b/pkg/spaddr/spinfo/spinfo_test.go @@ -1,7 +1,6 @@ package spinfo_test import ( - "context" "os" "testing" @@ -20,8 +19,7 @@ func TestSPAddrInfo(t *testing.T) { t.Skip("Skipping lotus test. Set STI_LOTUS_TEST=yes to enable.") } - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() addrInfo, err := spinfo.SPAddrInfo(ctx, gateway, testSPID) require.NoError(t, err)