Repository: libp2p/go-libp2p
Pull request #3295 (2025-05-23 18:55:50)

chore: fix errors reported by golangci-lint
This PR prepares go-libp2p for the addition of native golangci-lint support to UCI. I fix a bunch of errors reported by golangci-lint in this codebase and disable errcheck as it produces a huge number of errors and https://github.com/libp2p/go-libp2p/pull/3269 mentioned that there was some doubt whether it was going to be useful going forward.

#### Why the errors fixed here weren't reported by the current implementation of golangci-lint in CI?

This is because the added action was configured to check only the diff from the pull request i.e. it never runs checks over the entire codebase.

Unlike the default golangci-lint action, I propose the UCI implementation to run checks over the entire codebase in these cases:
- when the workflow is triggered by the push event
- when the pull request modifies either of
  - `go.mod`
  - `.github/workflows/go-check.yml`
  - `.golangci-lint.yaml`
  
Otherwise, it will behave the same as the action we use now and check only the diff.
  
#### Are there any other differences between the UCI implementation of golangci-lint and the action we use now?
 
Yes! The action we use now does not run checks in subpackages such as examples. The UCI implementation does.
 
Another difference is that the UCI implementation runs staticcheck and govet separately to golangci-lint. And when we run golangci-lint in CI, we exclude these linters. When you run golangci-lint without these exclusions locally, you might get slightly different results due to different versions of these tools being used. In the future, I'd like to explore using staticcheck and govet from golangci-lint to bridge this gap.

Finally, the UCI implementation of golangci-lint will only run the checks on linux. It won't run them with different GOOS settings. Is that OK?

#### How will UCI implementation of golangci-lint get enabled?

After UCI version with that feature is released, `go-check` will start running the golangci-lint step on ubuntu-latest if it finds a golangci-lint configuration file in the repository. We'll be able to remove the jobs that currently run golangci-lint here then.


Patch:
diff --git a/.golangci.yml b/.golangci.yml
index d3580944..13697f72 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -3,6 +3,10 @@ version: "2"
 run:
   timeout: 5m
 
+issues:
+  max-issues-per-linter: 0
+  max-same-issues: 0
+
 linters:
   enable:
     - revive
@@ -20,5 +24,4 @@ linters:
           severity: warning
 
 severity:
-    default: warning
-
+  default: warning
diff --git a/core/connmgr/null.go b/core/connmgr/null.go
index 73541171..3c7e6aef 100644
--- a/core/connmgr/null.go
+++ b/core/connmgr/null.go
@@ -16,10 +16,10 @@ func (NullConnMgr) TagPeer(peer.ID, string, int)             {}
 func (NullConnMgr) UntagPeer(peer.ID, string)                {}
 func (NullConnMgr) UpsertTag(peer.ID, string, func(int) int) {}
 func (NullConnMgr) GetTagInfo(peer.ID) *TagInfo              { return &TagInfo{} }
-func (NullConnMgr) TrimOpenConns(ctx context.Context)        {}
+func (NullConnMgr) TrimOpenConns(_ context.Context)          {}
 func (NullConnMgr) Notifee() network.Notifiee                { return network.GlobalNoopNotifiee }
 func (NullConnMgr) Protect(peer.ID, string)                  {}
 func (NullConnMgr) Unprotect(peer.ID, string) bool           { return false }
 func (NullConnMgr) IsProtected(peer.ID, string) bool         { return false }
-func (NullConnMgr) CheckLimit(l GetConnLimiter) error        { return nil }
+func (NullConnMgr) CheckLimit(_ GetConnLimiter) error        { return nil }
 func (NullConnMgr) Close() error                             { return nil }
diff --git a/core/connmgr/presets.go b/core/connmgr/presets.go
index 34bd1c07..b4f26313 100644
--- a/core/connmgr/presets.go
+++ b/core/connmgr/presets.go
@@ -61,7 +61,7 @@ func BumpSumBounded(min, max int) BumpFn {
 
 // BumpOverwrite replaces the current value of the tag with the incoming one.
 func BumpOverwrite() BumpFn {
-	return func(value DecayingValue, delta int) (after int) {
+	return func(_ DecayingValue, delta int) (after int) {
 		return delta
 	}
 }
diff --git a/core/crypto/secp256k1.go b/core/crypto/secp256k1.go
index 99e7464b..4798f395 100644
--- a/core/crypto/secp256k1.go
+++ b/core/crypto/secp256k1.go
@@ -19,7 +19,7 @@ type Secp256k1PrivateKey secp256k1.PrivateKey
 type Secp256k1PublicKey secp256k1.PublicKey
 
 // GenerateSecp256k1Key generates a new Secp256k1 private and public key pair
-func GenerateSecp256k1Key(src io.Reader) (PrivKey, PubKey, error) {
+func GenerateSecp256k1Key(_ io.Reader) (PrivKey, PubKey, error) {
 	privk, err := secp256k1.GeneratePrivateKey()
 	if err != nil {
 		return nil, nil, err
diff --git a/core/network/notifee.go b/core/network/notifee.go
index bb2f3833..525190e5 100644
--- a/core/network/notifee.go
+++ b/core/network/notifee.go
@@ -61,7 +61,7 @@ type NoopNotifiee struct{}
 
 var _ Notifiee = (*NoopNotifiee)(nil)
 
-func (nn *NoopNotifiee) Connected(n Network, c Conn)              {}
-func (nn *NoopNotifiee) Disconnected(n Network, c Conn)           {}
-func (nn *NoopNotifiee) Listen(n Network, addr ma.Multiaddr)      {}
-func (nn *NoopNotifiee) ListenClose(n Network, addr ma.Multiaddr) {}
+func (nn *NoopNotifiee) Connected(_ Network, _ Conn)           {}
+func (nn *NoopNotifiee) Disconnected(_ Network, _ Conn)        {}
+func (nn *NoopNotifiee) Listen(_ Network, _ ma.Multiaddr)      {}
+func (nn *NoopNotifiee) ListenClose(_ Network, _ ma.Multiaddr) {}
diff --git a/core/network/rcmgr.go b/core/network/rcmgr.go
index 3d31bcbf..83bbf4f1 100644
--- a/core/network/rcmgr.go
+++ b/core/network/rcmgr.go
@@ -320,19 +320,19 @@ func (n *NullResourceManager) ViewSystem(f func(ResourceScope) error) error {
 func (n *NullResourceManager) ViewTransient(f func(ResourceScope) error) error {
 	return f(&NullScope{})
 }
-func (n *NullResourceManager) ViewService(svc string, f func(ServiceScope) error) error {
+func (n *NullResourceManager) ViewService(_ string, f func(ServiceScope) error) error {
 	return f(&NullScope{})
 }
-func (n *NullResourceManager) ViewProtocol(p protocol.ID, f func(ProtocolScope) error) error {
+func (n *NullResourceManager) ViewProtocol(_ protocol.ID, f func(ProtocolScope) error) error {
 	return f(&NullScope{})
 }
-func (n *NullResourceManager) ViewPeer(p peer.ID, f func(PeerScope) error) error {
+func (n *NullResourceManager) ViewPeer(_ peer.ID, f func(PeerScope) error) error {
 	return f(&NullScope{})
 }
-func (n *NullResourceManager) OpenConnection(dir Direction, usefd bool, endpoint multiaddr.Multiaddr) (ConnManagementScope, error) {
+func (n *NullResourceManager) OpenConnection(_ Direction, _ bool, _ multiaddr.Multiaddr) (ConnManagementScope, error) {
 	return &NullScope{}, nil
 }
-func (n *NullResourceManager) OpenStream(p peer.ID, dir Direction) (StreamManagementScope, error) {
+func (n *NullResourceManager) OpenStream(_ peer.ID, _ Direction) (StreamManagementScope, error) {
 	return &NullScope{}, nil
 }
 func (*NullResourceManager) VerifySourceAddress(_ net.Addr) bool {
@@ -343,18 +343,18 @@ func (n *NullResourceManager) Close() error {
 	return nil
 }
 
-func (n *NullScope) ReserveMemory(size int, prio uint8) error { return nil }
-func (n *NullScope) ReleaseMemory(size int)                   {}
-func (n *NullScope) Stat() ScopeStat                          { return ScopeStat{} }
-func (n *NullScope) BeginSpan() (ResourceScopeSpan, error)    { return &NullScope{}, nil }
-func (n *NullScope) Done()                                    {}
-func (n *NullScope) Name() string                             { return "" }
-func (n *NullScope) Protocol() protocol.ID                    { return "" }
-func (n *NullScope) Peer() peer.ID                            { return "" }
-func (n *NullScope) PeerScope() PeerScope                     { return &NullScope{} }
-func (n *NullScope) SetPeer(peer.ID) error                    { return nil }
-func (n *NullScope) ProtocolScope() ProtocolScope             { return &NullScope{} }
-func (n *NullScope) SetProtocol(proto protocol.ID) error      { return nil }
-func (n *NullScope) ServiceScope() ServiceScope               { return &NullScope{} }
-func (n *NullScope) SetService(srv string) error              { return nil }
-func (n *NullScope) VerifySourceAddress(_ net.Addr) bool      { return false }
+func (n *NullScope) ReserveMemory(_ int, _ uint8) error    { return nil }
+func (n *NullScope) ReleaseMemory(_ int)                   {}
+func (n *NullScope) Stat() ScopeStat                       { return ScopeStat{} }
+func (n *NullScope) BeginSpan() (ResourceScopeSpan, error) { return &NullScope{}, nil }
+func (n *NullScope) Done()                                 {}
+func (n *NullScope) Name() string                          { return "" }
+func (n *NullScope) Protocol() protocol.ID                 { return "" }
+func (n *NullScope) Peer() peer.ID                         { return "" }
+func (n *NullScope) PeerScope() PeerScope                  { return &NullScope{} }
+func (n *NullScope) SetPeer(peer.ID) error                 { return nil }
+func (n *NullScope) ProtocolScope() ProtocolScope          { return &NullScope{} }
+func (n *NullScope) SetProtocol(_ protocol.ID) error       { return nil }
+func (n *NullScope) ServiceScope() ServiceScope            { return &NullScope{} }
+func (n *NullScope) SetService(_ string) error             { return nil }
+func (n *NullScope) VerifySourceAddress(_ net.Addr) bool   { return false }
diff --git a/examples/chat/chat.go b/examples/chat/chat.go
index d89ea3cd..1f88da4c 100644
--- a/examples/chat/chat.go
+++ b/examples/chat/chat.go
@@ -167,7 +167,7 @@ func makeHost(port int, randomness io.Reader) (host.Host, error) {
 	)
 }
 
-func startPeer(ctx context.Context, h host.Host, streamHandler network.StreamHandler) {
+func startPeer(_ context.Context, h host.Host, streamHandler network.StreamHandler) {
 	// Set a function as stream handler.
 	// This function is called when a peer connects, and starts a stream with this protocol.
 	// Only applies on the receiving side.
@@ -193,7 +193,7 @@ func startPeer(ctx context.Context, h host.Host, streamHandler network.StreamHan
 	log.Println()
 }
 
-func startPeerAndConnect(ctx context.Context, h host.Host, destination string) (*bufio.ReadWriter, error) {
+func startPeerAndConnect(_ context.Context, h host.Host, destination string) (*bufio.ReadWriter, error) {
 	log.Println("This node's multiaddresses:")
 	for _, la := range h.Addrs() {
 		log.Printf(" - %v\n", la)
diff --git a/examples/echo/main.go b/examples/echo/main.go
index 90c72486..18e031a8 100644
--- a/examples/echo/main.go
+++ b/examples/echo/main.go
@@ -96,7 +96,7 @@ func getHostAddress(ha host.Host) string {
 	return addr.Encapsulate(hostAddr).String()
 }
 
-func startListener(ctx context.Context, ha host.Host, listenPort int, insecure bool) {
+func startListener(_ context.Context, ha host.Host, listenPort int, insecure bool) {
 	fullAddr := getHostAddress(ha)
 	log.Printf("I am %s\n", fullAddr)
 
@@ -121,7 +121,7 @@ func startListener(ctx context.Context, ha host.Host, listenPort int, insecure b
 	}
 }
 
-func runSender(ctx context.Context, ha host.Host, targetPeer string) {
+func runSender(_ context.Context, ha host.Host, targetPeer string) {
 	fullAddr := getHostAddress(ha)
 	log.Printf("I am %s\n", fullAddr)
 
diff --git a/examples/ipfs-camp-2019/07-Messaging/pubsub.go b/examples/ipfs-camp-2019/07-Messaging/pubsub.go
index f40e7497..8245bbbb 100644
--- a/examples/ipfs-camp-2019/07-Messaging/pubsub.go
+++ b/examples/ipfs-camp-2019/07-Messaging/pubsub.go
@@ -16,7 +16,7 @@ func pubsubMessageHandler(id peer.ID, msg *SendMessage) {
 	fmt.Printf("%s: %s\n", id.ShortString(), msg.Data)
 }
 
-func pubsubUpdateHandler(id peer.ID, msg *UpdatePeer) {
+func pubsubUpdateHandler(_ peer.ID, _ *UpdatePeer) {
 
 }
 
diff --git a/options_filter.go b/options_filter.go
index 1f94ac3f..fa8df7a2 100644
--- a/options_filter.go
+++ b/options_filter.go
@@ -19,7 +19,7 @@ func (f *filtersConnectionGater) InterceptAddrDial(_ peer.ID, addr ma.Multiaddr)
 	return !(*ma.Filters)(f).AddrBlocked(addr)
 }
 
-func (f *filtersConnectionGater) InterceptPeerDial(p peer.ID) (allow bool) {
+func (f *filtersConnectionGater) InterceptPeerDial(_ peer.ID) (allow bool) {
 	return true
 }
 
diff --git a/p2p/discovery/backoff/backoff.go b/p2p/discovery/backoff/backoff.go
index 3fdfc085..94afc8c7 100644
--- a/p2p/discovery/backoff/backoff.go
+++ b/p2p/discovery/backoff/backoff.go
@@ -39,7 +39,7 @@ func FullJitter(duration, min, max time.Duration, rng *rand.Rand) time.Duration
 }
 
 // NoJitter returns the duration bounded between min and max
-func NoJitter(duration, min, max time.Duration, rng *rand.Rand) time.Duration {
+func NoJitter(duration, min, max time.Duration, _ *rand.Rand) time.Duration {
 	return boundedDuration(duration, min, max)
 }
 
diff --git a/p2p/discovery/mocks/mocks.go b/p2p/discovery/mocks/mocks.go
index be0c429d..3014538a 100644
--- a/p2p/discovery/mocks/mocks.go
+++ b/p2p/discovery/mocks/mocks.go
@@ -93,7 +93,7 @@ func NewDiscoveryClient(h host.Host, server *MockDiscoveryServer) *MockDiscovery
 	}
 }
 
-func (d *MockDiscoveryClient) Advertise(ctx context.Context, ns string, opts ...discovery.Option) (time.Duration, error) {
+func (d *MockDiscoveryClient) Advertise(_ context.Context, ns string, opts ...discovery.Option) (time.Duration, error) {
 	var options discovery.Options
 	err := options.Apply(opts...)
 	if err != nil {
@@ -103,7 +103,7 @@ func (d *MockDiscoveryClient) Advertise(ctx context.Context, ns string, opts ...
 	return d.server.Advertise(ns, *host.InfoFromHost(d.host), options.Ttl)
 }
 
-func (d *MockDiscoveryClient) FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan peer.AddrInfo, error) {
+func (d *MockDiscoveryClient) FindPeers(_ context.Context, ns string, opts ...discovery.Option) (<-chan peer.AddrInfo, error) {
 	var options discovery.Options
 	err := options.Apply(opts...)
 	if err != nil {
diff --git a/p2p/host/autonat/autonat.go b/p2p/host/autonat/autonat.go
index 6d3c9e24..59b5a453 100644
--- a/p2p/host/autonat/autonat.go
+++ b/p2p/host/autonat/autonat.go
@@ -270,7 +270,6 @@ func (as *AmbientAutoNAT) scheduleProbe(forceProbe bool) time.Duration {
 		// retry very quicky if forceProbe is true *and* we don't know our reachability
 		// limit all peers fetch from peerstore to 1 per second.
 		nextProbeAfter = 2 * time.Second
-		nextProbeAfter = 2 * time.Second
 	case currentStatus == network.ReachabilityUnknown,
 		as.confidence < maxConfidence,
 		currentStatus != network.ReachabilityPublic && receivedInbound:
diff --git a/p2p/host/autonat/notify.go b/p2p/host/autonat/notify.go
index a57bf156..6ae43262 100644
--- a/p2p/host/autonat/notify.go
+++ b/p2p/host/autonat/notify.go
@@ -10,13 +10,13 @@ import (
 var _ network.Notifiee = (*AmbientAutoNAT)(nil)
 
 // Listen is part of the network.Notifiee interface
-func (as *AmbientAutoNAT) Listen(net network.Network, a ma.Multiaddr) {}
+func (as *AmbientAutoNAT) Listen(_ network.Network, _ ma.Multiaddr) {}
 
 // ListenClose is part of the network.Notifiee interface
-func (as *AmbientAutoNAT) ListenClose(net network.Network, a ma.Multiaddr) {}
+func (as *AmbientAutoNAT) ListenClose(_ network.Network, _ ma.Multiaddr) {}
 
 // Connected is part of the network.Notifiee interface
-func (as *AmbientAutoNAT) Connected(net network.Network, c network.Conn) {
+func (as *AmbientAutoNAT) Connected(_ network.Network, c network.Conn) {
 	if c.Stat().Direction == network.DirInbound &&
 		manet.IsPublicAddr(c.RemoteMultiaddr()) {
 		select {
@@ -27,4 +27,4 @@ func (as *AmbientAutoNAT) Connected(net network.Network, c network.Conn) {
 }
 
 // Disconnected is part of the network.Notifiee interface
-func (as *AmbientAutoNAT) Disconnected(net network.Network, c network.Conn) {}
+func (as *AmbientAutoNAT) Disconnected(_ network.Network, _ network.Conn) {}
diff --git a/p2p/host/autorelay/options.go b/p2p/host/autorelay/options.go
index 26ba9201..7207c0f6 100644
--- a/p2p/host/autorelay/options.go
+++ b/p2p/host/autorelay/options.go
@@ -67,7 +67,7 @@ func WithStaticRelays(static []peer.AddrInfo) Option {
 			return errAlreadyHavePeerSource
 		}
 
-		WithPeerSource(func(ctx context.Context, numPeers int) <-chan peer.AddrInfo {
+		WithPeerSource(func(_ context.Context, numPeers int) <-chan peer.AddrInfo {
 			if len(static) < numPeers {
 				numPeers = len(static)
 			}
diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go
index 70c6b2a1..476ea9b2 100644
--- a/p2p/host/basic/basic_host.go
+++ b/p2p/host/basic/basic_host.go
@@ -539,7 +539,7 @@ func (h *BasicHost) EventBus() event.Bus {
 //
 // (Thread-safe)
 func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler) {
-	h.Mux().AddHandler(pid, func(p protocol.ID, rwc io.ReadWriteCloser) error {
+	h.Mux().AddHandler(pid, func(_ protocol.ID, rwc io.ReadWriteCloser) error {
 		is := rwc.(network.Stream)
 		handler(is)
 		return nil
@@ -552,7 +552,7 @@ func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler network.StreamHand
 // SetStreamHandlerMatch sets the protocol handler on the Host's Mux
 // using a matching function to do protocol comparisons
 func (h *BasicHost) SetStreamHandlerMatch(pid protocol.ID, m func(protocol.ID) bool, handler network.StreamHandler) {
-	h.Mux().AddHandlerWithFunc(pid, m, func(p protocol.ID, rwc io.ReadWriteCloser) error {
+	h.Mux().AddHandlerWithFunc(pid, m, func(_ protocol.ID, rwc io.ReadWriteCloser) error {
 		is := rwc.(network.Stream)
 		handler(is)
 		return nil
diff --git a/p2p/host/basic/natmgr.go b/p2p/host/basic/natmgr.go
index 4abe8dd0..bbd6ceb3 100644
--- a/p2p/host/basic/natmgr.go
+++ b/p2p/host/basic/natmgr.go
@@ -292,8 +292,8 @@ func (nmgr *natManager) GetMapping(addr ma.Multiaddr) ma.Multiaddr {
 
 type nmgrNetNotifiee natManager
 
-func (nn *nmgrNetNotifiee) natManager() *natManager                          { return (*natManager)(nn) }
-func (nn *nmgrNetNotifiee) Listen(network.Network, ma.Multiaddr)             { nn.natManager().sync() }
-func (nn *nmgrNetNotifiee) ListenClose(n network.Network, addr ma.Multiaddr) { nn.natManager().sync() }
-func (nn *nmgrNetNotifiee) Connected(network.Network, network.Conn)          {}
-func (nn *nmgrNetNotifiee) Disconnected(network.Network, network.Conn)       {}
+func (nn *nmgrNetNotifiee) natManager() *natManager                       { return (*natManager)(nn) }
+func (nn *nmgrNetNotifiee) Listen(network.Network, ma.Multiaddr)          { nn.natManager().sync() }
+func (nn *nmgrNetNotifiee) ListenClose(_ network.Network, _ ma.Multiaddr) { nn.natManager().sync() }
+func (nn *nmgrNetNotifiee) Connected(network.Network, network.Conn)       {}
+func (nn *nmgrNetNotifiee) Disconnected(network.Network, network.Conn)    {}
diff --git a/p2p/host/peerstore/pstoreds/addr_book.go b/p2p/host/peerstore/pstoreds/addr_book.go
index 2023de12..ee80ecd8 100644
--- a/p2p/host/peerstore/pstoreds/addr_book.go
+++ b/p2p/host/peerstore/pstoreds/addr_book.go
@@ -470,7 +470,7 @@ func (ab *dsAddrBook) ClearAddrs(p peer.ID) {
 	}
 }
 
-func (ab *dsAddrBook) setAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration, mode ttlWriteMode, signed bool) (err error) {
+func (ab *dsAddrBook) setAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration, mode ttlWriteMode, _ bool) (err error) {
 	if len(addrs) == 0 {
 		return nil
 	}
diff --git a/p2p/host/peerstore/pstoreds/cache.go b/p2p/host/peerstore/pstoreds/cache.go
index b2bbc9a9..184944f4 100644
--- a/p2p/host/peerstore/pstoreds/cache.go
+++ b/p2p/host/peerstore/pstoreds/cache.go
@@ -17,21 +17,21 @@ type noopCache[K comparable, V any] struct {
 
 var _ cache[int, int] = (*noopCache[int, int])(nil)
 
-func (*noopCache[K, V]) Get(key K) (value V, ok bool) {
+func (*noopCache[K, V]) Get(_ K) (value V, ok bool) {
 	return *new(V), false
 }
 
-func (*noopCache[K, V]) Add(key K, value V) {
+func (*noopCache[K, V]) Add(_ K, _ V) {
 }
 
-func (*noopCache[K, V]) Remove(key K) {
+func (*noopCache[K, V]) Remove(_ K) {
 }
 
-func (*noopCache[K, V]) Contains(key K) bool {
+func (*noopCache[K, V]) Contains(_ K) bool {
 	return false
 }
 
-func (*noopCache[K, V]) Peek(key K) (value V, ok bool) {
+func (*noopCache[K, V]) Peek(_ K) (value V, ok bool) {
 	return *new(V), false
 }
 
diff --git a/p2p/host/peerstore/pstoreds/cyclic_batch.go b/p2p/host/peerstore/pstoreds/cyclic_batch.go
index 51f6afb0..17a30f91 100644
--- a/p2p/host/peerstore/pstoreds/cyclic_batch.go
+++ b/p2p/host/peerstore/pstoreds/cyclic_batch.go
@@ -23,7 +23,7 @@ type cyclicBatch struct {
 	pending int
 }
 
-func newCyclicBatch(ds ds.Batching, threshold int) (ds.Batch, error) {
+func newCyclicBatch(ds ds.Batching, _ int) (ds.Batch, error) {
 	batch, err := ds.Batch(context.TODO())
 	if err != nil {
 		return nil, err
diff --git a/p2p/net/conngater/conngater.go b/p2p/net/conngater/conngater.go
index 8c9084c5..1fb6a28f 100644
--- a/p2p/net/conngater/conngater.go
+++ b/p2p/net/conngater/conngater.go
@@ -282,7 +282,7 @@ func (cg *BasicConnectionGater) InterceptPeerDial(p peer.ID) (allow bool) {
 	return !block
 }
 
-func (cg *BasicConnectionGater) InterceptAddrDial(p peer.ID, a ma.Multiaddr) (allow bool) {
+func (cg *BasicConnectionGater) InterceptAddrDial(_ peer.ID, a ma.Multiaddr) (allow bool) {
 	// we have already filtered blocked peers in InterceptPeerDial, so we just check the IP
 	cg.RLock()
 	defer cg.RUnlock()
@@ -333,7 +333,7 @@ func (cg *BasicConnectionGater) InterceptAccept(cma network.ConnMultiaddrs) (all
 	return true
 }
 
-func (cg *BasicConnectionGater) InterceptSecured(dir network.Direction, p peer.ID, cma network.ConnMultiaddrs) (allow bool) {
+func (cg *BasicConnectionGater) InterceptSecured(dir network.Direction, p peer.ID, _ network.ConnMultiaddrs) (allow bool) {
 	if dir == network.DirOutbound {
 		// we have already filtered those in InterceptPeerDial/InterceptAddrDial
 		return true
diff --git a/p2p/net/connmgr/connmgr.go b/p2p/net/connmgr/connmgr.go
index 57fc7da1..2511ea1c 100644
--- a/p2p/net/connmgr/connmgr.go
+++ b/p2p/net/connmgr/connmgr.go
@@ -660,7 +660,7 @@ func (nn *cmNotifee) cm() *BasicConnMgr {
 // Connected is called by notifiers to inform that a new connection has been established.
 // The notifee updates the BasicConnMgr to start tracking the connection. If the new connection
 // count exceeds the high watermark, a trim may be triggered.
-func (nn *cmNotifee) Connected(n network.Network, c network.Conn) {
+func (nn *cmNotifee) Connected(_ network.Network, c network.Conn) {
 	cm := nn.cm()
 
 	p := c.RemotePeer()
@@ -699,7 +699,7 @@ func (nn *cmNotifee) Connected(n network.Network, c network.Conn) {
 
 // Disconnected is called by notifiers to inform that an existing connection has been closed or terminated.
 // The notifee updates the BasicConnMgr accordingly to stop tracking the connection, and performs housekeeping.
-func (nn *cmNotifee) Disconnected(n network.Network, c network.Conn) {
+func (nn *cmNotifee) Disconnected(_ network.Network, c network.Conn) {
 	cm := nn.cm()
 
 	p := c.RemotePeer()
@@ -727,7 +727,7 @@ func (nn *cmNotifee) Disconnected(n network.Network, c network.Conn) {
 }
 
 // Listen is no-op in this implementation.
-func (nn *cmNotifee) Listen(n network.Network, addr ma.Multiaddr) {}
+func (nn *cmNotifee) Listen(_ network.Network, _ ma.Multiaddr) {}
 
 // ListenClose is no-op in this implementation.
-func (nn *cmNotifee) ListenClose(n network.Network, addr ma.Multiaddr) {}
+func (nn *cmNotifee) ListenClose(_ network.Network, _ ma.Multiaddr) {}
diff --git a/p2p/net/mock/mock_peernet.go b/p2p/net/mock/mock_peernet.go
index 0b525d3e..3d48910d 100644
--- a/p2p/net/mock/mock_peernet.go
+++ b/p2p/net/mock/mock_peernet.go
@@ -106,7 +106,7 @@ func (pn *peernet) handleNewStream(s network.Stream) {
 
 // DialPeer attempts to establish a connection to a given peer.
 // Respects the context.
-func (pn *peernet) DialPeer(ctx context.Context, p peer.ID) (network.Conn, error) {
+func (pn *peernet) DialPeer(_ context.Context, p peer.ID) (network.Conn, error) {
 	return pn.connect(p)
 }
 
@@ -151,7 +151,7 @@ func (pn *peernet) connect(p peer.ID) (*conn, error) {
 	return pn.openConn(p, l.(*link))
 }
 
-func (pn *peernet) openConn(r peer.ID, l *link) (*conn, error) {
+func (pn *peernet) openConn(_ peer.ID, l *link) (*conn, error) {
 	lc, rc := l.newConnPair(pn)
 	addConnPair(pn, rc.net, lc, rc)
 	log.Debugf("%s opening connection to %s", pn.LocalPeer(), lc.RemotePeer())
@@ -435,6 +435,6 @@ func (pn *peernet) ResourceManager() network.ResourceManager {
 	return &network.NullResourceManager{}
 }
 
-func (pn *peernet) CanDial(p peer.ID, addr ma.Multiaddr) bool {
+func (pn *peernet) CanDial(_ peer.ID, _ ma.Multiaddr) bool {
 	return true
 }
diff --git a/p2p/net/mock/mock_stream.go b/p2p/net/mock/mock_stream.go
index 27e32d9e..ed518b7e 100644
--- a/p2p/net/mock/mock_stream.go
+++ b/p2p/net/mock/mock_stream.go
@@ -174,15 +174,15 @@ func (s *stream) Conn() network.Conn {
 	return s.conn
 }
 
-func (s *stream) SetDeadline(t time.Time) error {
+func (s *stream) SetDeadline(_ time.Time) error {
 	return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
 }
 
-func (s *stream) SetReadDeadline(t time.Time) error {
+func (s *stream) SetReadDeadline(_ time.Time) error {
 	return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
 }
 
-func (s *stream) SetWriteDeadline(t time.Time) error {
+func (s *stream) SetWriteDeadline(_ time.Time) error {
 	return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
 }
 
diff --git a/p2p/net/nat/internal/nat/nat.go b/p2p/net/nat/internal/nat/nat.go
index ccbf87de..d2926870 100644
--- a/p2p/net/nat/internal/nat/nat.go
+++ b/p2p/net/nat/internal/nat/nat.go
@@ -29,7 +29,7 @@ func (e ErrNoNATFound) Unwrap() []error {
 }
 
 func (e ErrNoNATFound) Error() string {
-	var errStrs []string
+	errStrs := make([]string, 0, len(e.Errs))
 	for _, err := range e.Errs {
 		errStrs = append(errStrs, err.Error())
 	}
diff --git a/p2p/net/reuseport/dial.go b/p2p/net/reuseport/dial.go
index 6a3d18ff..e162813d 100644
--- a/p2p/net/reuseport/dial.go
+++ b/p2p/net/reuseport/dial.go
@@ -45,7 +45,7 @@ func (t *Transport) DialContext(ctx context.Context, raddr ma.Multiaddr) (manet.
 	return maconn, nil
 }
 
-func (n *network) getDialer(network string) *dialer {
+func (n *network) getDialer(_ string) *dialer {
 	n.mu.RLock()
 	d := n.dialer
 	n.mu.RUnlock()
diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go
index 35fc567f..b7cf8b25 100644
--- a/p2p/net/swarm/swarm_dial.go
+++ b/p2p/net/swarm/swarm_dial.go
@@ -405,7 +405,7 @@ func (s *Swarm) resolveAddrs(ctx context.Context, pi peer.AddrInfo) []ma.Multiad
 			return ok
 
 		},
-		resolve: func(ctx context.Context, addr ma.Multiaddr, outputLimit int) ([]ma.Multiaddr, error) {
+		resolve: func(ctx context.Context, addr ma.Multiaddr, _ int) ([]ma.Multiaddr, error) {
 			tpt := s.TransportForDialing(addr)
 			resolver, ok := tpt.(transport.SkipResolver)
 			if !ok {
diff --git a/p2p/protocol/circuitv2/client/transport.go b/p2p/protocol/circuitv2/client/transport.go
index 553f8fa5..7f0e9856 100644
--- a/p2p/protocol/circuitv2/client/transport.go
+++ b/p2p/protocol/circuitv2/client/transport.go
@@ -56,7 +56,7 @@ var _ io.Closer = (*Client)(nil)
 // SkipResolve returns true since we always defer to the inner transport for
 // the actual connection. By skipping resolution here, we let the inner
 // transport decide how to resolve the multiaddr
-func (c *Client) SkipResolve(ctx context.Context, maddr ma.Multiaddr) bool {
+func (c *Client) SkipResolve(_ context.Context, _ ma.Multiaddr) bool {
 	return true
 }
 
diff --git a/p2p/protocol/circuitv2/relay/relay.go b/p2p/protocol/circuitv2/relay/relay.go
index 326d1778..3fb6646c 100644
--- a/p2p/protocol/circuitv2/relay/relay.go
+++ b/p2p/protocol/circuitv2/relay/relay.go
@@ -591,7 +591,7 @@ func makeReservationMsg(
 		return rsvp
 	}
 
-	var addrBytes [][]byte
+	addrBytes := make([][]byte, 0, len(selfAddrs))
 	for _, addr := range selfAddrs {
 		if !manet.IsPublicAddr(addr) {
 			continue
@@ -638,7 +638,7 @@ func makeReservationMsg(
 	return rsvp
 }
 
-func (r *Relay) makeLimitMsg(p peer.ID) *pbv2.Limit {
+func (r *Relay) makeLimitMsg(_ peer.ID) *pbv2.Limit {
 	if r.rc.Limit == nil {
 		return nil
 	}
diff --git a/p2p/protocol/holepunch/holepuncher.go b/p2p/protocol/holepunch/holepuncher.go
index d93bda25..c761a475 100644
--- a/p2p/protocol/holepunch/holepuncher.go
+++ b/p2p/protocol/holepunch/holepuncher.go
@@ -302,6 +302,6 @@ func (nn *netNotifiee) Connected(_ network.Network, conn network.Conn) {
 	}
 }
 
-func (nn *netNotifiee) Disconnected(_ network.Network, v network.Conn) {}
-func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr)       {}
-func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr)  {}
+func (nn *netNotifiee) Disconnected(_ network.Network, _ network.Conn) {}
+func (nn *netNotifiee) Listen(_ network.Network, _ ma.Multiaddr)       {}
+func (nn *netNotifiee) ListenClose(_ network.Network, _ ma.Multiaddr)  {}
diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go
index f104b464..f4c6f960 100644
--- a/p2p/protocol/identify/id.go
+++ b/p2p/protocol/identify/id.go
@@ -1104,8 +1104,8 @@ func (nn *netNotifiee) Disconnected(_ network.Network, c network.Conn) {
 	ids.Host.Peerstore().UpdateAddrs(c.RemotePeer(), peerstore.TempAddrTTL, 0)
 }
 
-func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr)      {}
-func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {}
+func (nn *netNotifiee) Listen(_ network.Network, _ ma.Multiaddr)      {}
+func (nn *netNotifiee) ListenClose(_ network.Network, _ ma.Multiaddr) {}
 
 // filterAddrs filters the address slice based on the remote multiaddr:
 //   - if it's a localhost address, no filtering is applied
diff --git a/p2p/transport/quicreuse/connmgr.go b/p2p/transport/quicreuse/connmgr.go
index 49d6f7da..ac5d1445 100644
--- a/p2p/transport/quicreuse/connmgr.go
+++ b/p2p/transport/quicreuse/connmgr.go
@@ -135,7 +135,7 @@ func NewConnManager(statelessResetKey quic.StatelessResetKey, tokenKey quic.Toke
 }
 
 func (c *ConnManager) getTracer() func(context.Context, quiclogging.Perspective, quic.ConnectionID) *quiclogging.ConnectionTracer {
-	return func(ctx context.Context, p quiclogging.Perspective, ci quic.ConnectionID) *quiclogging.ConnectionTracer {
+	return func(_ context.Context, p quiclogging.Perspective, ci quic.ConnectionID) *quiclogging.ConnectionTracer {
 		var promTracer *quiclogging.ConnectionTracer
 		if c.enableMetrics {
 			switch p {
diff --git a/p2p/transport/quicreuse/nonquic_packetconn.go b/p2p/transport/quicreuse/nonquic_packetconn.go
index d96a3de9..3fc5ad7c 100644
--- a/p2p/transport/quicreuse/nonquic_packetconn.go
+++ b/p2p/transport/quicreuse/nonquic_packetconn.go
@@ -59,7 +59,7 @@ func (n *nonQUICPacketConn) SetReadDeadline(t time.Time) error {
 }
 
 // SetWriteDeadline implements net.PacketConn.
-func (n *nonQUICPacketConn) SetWriteDeadline(t time.Time) error {
+func (n *nonQUICPacketConn) SetWriteDeadline(_ time.Time) error {
 	// Unused. quic-go doesn't support deadlines for writes.
 	return nil
 }
diff --git a/p2p/transport/tcp/metrics_general.go b/p2p/transport/tcp/metrics_general.go
index 419fff36..07ebd1a5 100644
--- a/p2p/transport/tcp/metrics_general.go
+++ b/p2p/transport/tcp/metrics_general.go
@@ -9,7 +9,7 @@ const (
 	hasByteCounter    = false
 )
 
-func getSegmentsSent(info *tcpinfo.Info) uint64 { return 0 }
-func getSegmentsRcvd(info *tcpinfo.Info) uint64 { return 0 }
-func getBytesSent(info *tcpinfo.Info) uint64    { return 0 }
-func getBytesRcvd(info *tcpinfo.Info) uint64    { return 0 }
+func getSegmentsSent(_ *tcpinfo.Info) uint64 { return 0 }
+func getSegmentsRcvd(_ *tcpinfo.Info) uint64 { return 0 }
+func getBytesSent(_ *tcpinfo.Info) uint64    { return 0 }
+func getBytesRcvd(_ *tcpinfo.Info) uint64    { return 0 }
diff --git a/p2p/transport/tcp/metrics_linux.go b/p2p/transport/tcp/metrics_linux.go
index b73d300d..a1a10ee3 100644
--- a/p2p/transport/tcp/metrics_linux.go
+++ b/p2p/transport/tcp/metrics_linux.go
@@ -11,5 +11,5 @@ const (
 
 func getSegmentsSent(info *tcpinfo.Info) uint64 { return uint64(info.Sys.SegsOut) }
 func getSegmentsRcvd(info *tcpinfo.Info) uint64 { return uint64(info.Sys.SegsIn) }
-func getBytesSent(info *tcpinfo.Info) uint64    { return 0 }
-func getBytesRcvd(info *tcpinfo.Info) uint64    { return 0 }
+func getBytesSent(_ *tcpinfo.Info) uint64       { return 0 }
+func getBytesRcvd(_ *tcpinfo.Info) uint64       { return 0 }
diff --git a/p2p/transport/webrtc/listener.go b/p2p/transport/webrtc/listener.go
index 0ec05ec0..ac110fde 100644
--- a/p2p/transport/webrtc/listener.go
+++ b/p2p/transport/webrtc/listener.go
@@ -333,7 +333,7 @@ func (l *listener) Multiaddr() ma.Multiaddr {
 func addOnConnectionStateChangeCallback(pc *webrtc.PeerConnection) <-chan error {
 	errC := make(chan error, 1)
 	var once sync.Once
-	pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
+	pc.OnConnectionStateChange(func(_ webrtc.PeerConnectionState) {
 		switch pc.ConnectionState() {
 		case webrtc.PeerConnectionStateConnected:
 			once.Do(func() { close(errC) })
diff --git a/p2p/transport/webrtc/logger.go b/p2p/transport/webrtc/logger.go
index ebe5fa30..c916a0e0 100644
--- a/p2p/transport/webrtc/logger.go
+++ b/p2p/transport/webrtc/logger.go
@@ -63,7 +63,7 @@ type loggerFactory struct{}
 // NewLogger returns pLog for all new logger instances. Internally pion creates lots of
 // separate logging objects unnecessarily. To avoid the allocations we use a single log
 // object for all of pion logging.
-func (loggerFactory) NewLogger(scope string) pionLogging.LeveledLogger {
+func (loggerFactory) NewLogger(_ string) pionLogging.LeveledLogger {
 	return pLog
 }
 
diff --git a/p2p/transport/webrtc/transport.go b/p2p/transport/webrtc/transport.go
index f3322c81..8a5fd335 100644
--- a/p2p/transport/webrtc/transport.go
+++ b/p2p/transport/webrtc/transport.go
@@ -624,7 +624,7 @@ func newWebRTCConnection(settings webrtc.SettingEngine, config webrtc.Configurat
 	})
 
 	connectionClosedCh := make(chan struct{}, 1)
-	pc.SCTP().OnClose(func(err error) {
+	pc.SCTP().OnClose(func(_ error) {
 		// We only need one message. Closing a connection is a problem as pion might invoke the callback more than once.
 		select {
 		case connectionClosedCh <- struct{}{}:
diff --git a/p2p/transport/webrtc/udpmux/muxed_connection.go b/p2p/transport/webrtc/udpmux/muxed_connection.go
index 84d30c84..64fa1d98 100644
--- a/p2p/transport/webrtc/udpmux/muxed_connection.go
+++ b/p2p/transport/webrtc/udpmux/muxed_connection.go
@@ -103,17 +103,17 @@ func (c *muxedConnection) close() {
 
 func (c *muxedConnection) LocalAddr() net.Addr { return c.mux.socket.LocalAddr() }
 
-func (*muxedConnection) SetDeadline(t time.Time) error {
+func (*muxedConnection) SetDeadline(_ time.Time) error {
 	// no deadline is desired here
 	return nil
 }
 
-func (*muxedConnection) SetReadDeadline(t time.Time) error {
+func (*muxedConnection) SetReadDeadline(_ time.Time) error {
 	// no read deadline is desired here
 	return nil
 }
 
-func (*muxedConnection) SetWriteDeadline(t time.Time) error {
+func (*muxedConnection) SetWriteDeadline(_ time.Time) error {
 	// no write deadline is desired here
 	return nil
 }
diff --git a/p2p/transport/websocket/listener.go b/p2p/transport/websocket/listener.go
index b7402c0e..d275c612 100644
--- a/p2p/transport/websocket/listener.go
+++ b/p2p/transport/websocket/listener.go
@@ -121,7 +121,7 @@ func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMg
 		wsurl:    wsurl,
 		wsUpgrader: ws.Upgrader{
 			// Allow requests from *all* origins.
-			CheckOrigin: func(r *http.Request) bool {
+			CheckOrigin: func(_ *http.Request) bool {
 				return true
 			},
 			HandshakeTimeout: handshakeTimeout,
diff --git a/p2p/transport/webtransport/listener.go b/p2p/transport/webtransport/listener.go
index 12ddd8d0..546bf469 100644
--- a/p2p/transport/webtransport/listener.go
+++ b/p2p/transport/webtransport/listener.go
@@ -110,7 +110,7 @@ func newListener(reuseListener quicreuse.Listener, t *transport, isStaticTLSConf
 					return context.WithValue(ctx, connKey{}, c)
 				},
 			},
-			CheckOrigin: func(r *http.Request) bool { return true },
+			CheckOrigin: func(_ *http.Request) bool { return true },
 		},
 	}
 	ln.ctx, ln.ctxCancel = context.WithCancel(context.Background())
diff --git a/p2p/transport/webtransport/transport.go b/p2p/transport/webtransport/transport.go
index 00a0112b..2719795a 100644
--- a/p2p/transport/webtransport/transport.go
+++ b/p2p/transport/webtransport/transport.go
@@ -215,7 +215,7 @@ func (t *transport) dial(ctx context.Context, addr ma.Multiaddr, url, sni string
 		return nil, nil, err
 	}
 	dialer := webtransport.Dialer{
-		DialAddr: func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
+		DialAddr: func(_ context.Context, _ string, _ *tls.Config, _ *quic.Config) (quic.EarlyConnection, error) {
 			return conn.(quic.EarlyConnection), nil
 		},
 		QUICConfig: t.connManager.ClientConfig().Clone(),


Test patch:
diff --git a/config/config_test.go b/config/config_test.go
index 7f99b833..652d807d 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -7,7 +7,7 @@ import (
 func TestNilOption(t *testing.T) {
 	var cfg Config
 	optsRun := 0
-	opt := func(c *Config) error {
+	opt := func(_ *Config) error {
 		optsRun++
 		return nil
 	}
diff --git a/core/record/envelope_test.go b/core/record/envelope_test.go
index 54ee5238..a8f8cb57 100644
--- a/core/record/envelope_test.go
+++ b/core/record/envelope_test.go
@@ -91,8 +91,8 @@ func TestEnvelopeHappyPath(t *testing.T) {
 
 func TestConsumeTypedEnvelope(t *testing.T) {
 	var (
-		rec          = simpleRecord{message: "hello world!"}
-		priv, _, err = test.RandTestKeyPair(crypto.Ed25519, 256)
+		rec        = simpleRecord{message: "hello world!"}
+		priv, _, _ = test.RandTestKeyPair(crypto.Ed25519, 256)
 	)
 
 	envelope, err := Seal(&rec, priv)
@@ -164,7 +164,7 @@ func (r failingRecord) MarshalRecord() ([]byte, error) {
 	}
 	return nil, errors.New("marshal failed")
 }
-func (r failingRecord) UnmarshalRecord(data []byte) error {
+func (r failingRecord) UnmarshalRecord(_ []byte) error {
 	if r.allowUnmarshal {
 		return nil
 	}
diff --git a/core/record/record_test.go b/core/record/record_test.go
index 63796402..033ee7fe 100644
--- a/core/record/record_test.go
+++ b/core/record/record_test.go
@@ -20,7 +20,7 @@ func (p *testPayload) MarshalRecord() ([]byte, error) {
 	return []byte("hello"), nil
 }
 
-func (p *testPayload) UnmarshalRecord(bytes []byte) error {
+func (p *testPayload) UnmarshalRecord(_ []byte) error {
 	p.unmarshalPayloadCalled = true
 	return nil
 }
diff --git a/libp2p_test.go b/libp2p_test.go
index f10bbb9b..15625e8f 100644
--- a/libp2p_test.go
+++ b/libp2p_test.go
@@ -56,7 +56,7 @@ func TestNewHost(t *testing.T) {
 
 func TestTransportConstructor(t *testing.T) {
 	ctor := func(
-		h host.Host,
+		_ host.Host,
 		_ connmgr.ConnectionGater,
 		upgrader transport.Upgrader,
 	) transport.Transport {
@@ -157,7 +157,7 @@ func TestChainOptions(t *testing.T) {
 	newOpt := func() Option {
 		index := optcount
 		optcount++
-		return func(c *Config) error {
+		return func(_ *Config) error {
 			optsRun = append(optsRun, index)
 			return nil
 		}
@@ -321,7 +321,7 @@ func TestTransportCustomAddressWebTransport(t *testing.T) {
 		Transport(webtransport.New),
 		ListenAddrs(customAddr),
 		DisableRelay(),
-		AddrsFactory(func(multiaddrs []ma.Multiaddr) []ma.Multiaddr {
+		AddrsFactory(func(_ []ma.Multiaddr) []ma.Multiaddr {
 			return []ma.Multiaddr{customAddr}
 		}),
 	)
@@ -351,7 +351,7 @@ func TestTransportCustomAddressWebTransportDoesNotStall(t *testing.T) {
 		// Purposely not listening on the custom address so that we make sure the node doesn't stall if it fails to add a certhash to the multiaddr
 		// ListenAddrs(customAddr),
 		DisableRelay(),
-		AddrsFactory(func(multiaddrs []ma.Multiaddr) []ma.Multiaddr {
+		AddrsFactory(func(_ []ma.Multiaddr) []ma.Multiaddr {
 			return []ma.Multiaddr{customAddr}
 		}),
 	)
@@ -478,7 +478,7 @@ func TestDialCircuitAddrWithWrappedResourceManager(t *testing.T) {
 func TestHostAddrsFactoryAddsCerthashes(t *testing.T) {
 	addr := ma.StringCast("/ip4/1.2.3.4/udp/1/quic-v1/webtransport")
 	h, err := New(
-		AddrsFactory(func(m []ma.Multiaddr) []ma.Multiaddr {
+		AddrsFactory(func(_ []ma.Multiaddr) []ma.Multiaddr {
 			return []ma.Multiaddr{addr}
 		}),
 	)
@@ -786,7 +786,7 @@ func TestSharedTCPAddr(t *testing.T) {
 
 func TestCustomTCPDialer(t *testing.T) {
 	expectedErr := errors.New("custom dialer called, but not implemented")
-	customDialer := func(raddr ma.Multiaddr) (tcp.ContextDialer, error) {
+	customDialer := func(_ ma.Multiaddr) (tcp.ContextDialer, error) {
 		// Normally a user would implement this by returning a custom dialer
 		// Here, we just test that this is called.
 		return nil, expectedErr
diff --git a/p2p/discovery/backoff/backoff_test.go b/p2p/discovery/backoff/backoff_test.go
index 56b115d1..e31ea1c8 100644
--- a/p2p/discovery/backoff/backoff_test.go
+++ b/p2p/discovery/backoff/backoff_test.go
@@ -21,9 +21,7 @@ func TestFixedBackoff(t *testing.T) {
 	delay := startDelay
 
 	bkf := NewFixedBackoff(delay)
-	delay *= 2
 	b1 := bkf()
-	delay *= 2
 	b2 := bkf()
 
 	if b1.Delay() != startDelay || b2.Delay() != startDelay {
@@ -129,17 +127,17 @@ func TestManyBackoffFactory(t *testing.T) {
 	rngSource := rand.NewSource(0)
 	concurrent := 10
 
-	t.Run("Exponential", func(t *testing.T) {
+	t.Run("Exponential", func(_ *testing.T) {
 		testManyBackoffFactoryHelper(concurrent,
 			NewExponentialBackoff(time.Millisecond*650, time.Second*7, FullJitter, time.Second, 1.5, -time.Millisecond*400, rngSource),
 		)
 	})
-	t.Run("Polynomial", func(t *testing.T) {
+	t.Run("Polynomial", func(_ *testing.T) {
 		testManyBackoffFactoryHelper(concurrent,
 			NewPolynomialBackoff(time.Second, time.Second*33, NoJitter, time.Second, []float64{0.5, 2, 3}, rngSource),
 		)
 	})
-	t.Run("Fixed", func(t *testing.T) {
+	t.Run("Fixed", func(_ *testing.T) {
 		testManyBackoffFactoryHelper(concurrent,
 			NewFixedBackoff(time.Second),
 		)
diff --git a/p2p/discovery/routing/routing_test.go b/p2p/discovery/routing/routing_test.go
index 6e28c06f..d6dce1de 100644
--- a/p2p/discovery/routing/routing_test.go
+++ b/p2p/discovery/routing/routing_test.go
@@ -36,7 +36,7 @@ func NewMockRouting(h host.Host, tab *mockRoutingTable) *mockRouting {
 	return &mockRouting{h: h, tab: tab}
 }
 
-func (m *mockRouting) Provide(ctx context.Context, cid cid.Cid, bcast bool) error {
+func (m *mockRouting) Provide(_ context.Context, cid cid.Cid, _ bool) error {
 	m.tab.mx.Lock()
 	defer m.tab.mx.Unlock()
 
@@ -51,7 +51,7 @@ func (m *mockRouting) Provide(ctx context.Context, cid cid.Cid, bcast bool) erro
 	return nil
 }
 
-func (m *mockRouting) FindProvidersAsync(ctx context.Context, cid cid.Cid, limit int) <-chan peer.AddrInfo {
+func (m *mockRouting) FindProvidersAsync(ctx context.Context, cid cid.Cid, _ int) <-chan peer.AddrInfo {
 	ch := make(chan peer.AddrInfo)
 	go func() {
 		defer close(ch)
diff --git a/p2p/host/autonat/dialpolicy_test.go b/p2p/host/autonat/dialpolicy_test.go
index 4bcf91c9..61660832 100644
--- a/p2p/host/autonat/dialpolicy_test.go
+++ b/p2p/host/autonat/dialpolicy_test.go
@@ -28,11 +28,11 @@ type mockT struct {
 	addr   multiaddr.Multiaddr
 }
 
-func (m *mockT) Dial(ctx context.Context, a multiaddr.Multiaddr, p peer.ID) (transport.CapableConn, error) {
+func (m *mockT) Dial(_ context.Context, _ multiaddr.Multiaddr, _ peer.ID) (transport.CapableConn, error) {
 	return nil, nil
 }
 func (m *mockT) CanDial(_ multiaddr.Multiaddr) bool { return true }
-func (m *mockT) Listen(a multiaddr.Multiaddr) (transport.Listener, error) {
+func (m *mockT) Listen(_ multiaddr.Multiaddr) (transport.Listener, error) {
 	return &mockL{m.ctx, m.cancel, m.addr}, nil
 }
 func (m *mockT) Protocols() []int { return []int{multiaddr.P_IP4} }
diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go
index 757d43f2..f44daa07 100644
--- a/p2p/host/basic/basic_host_test.go
+++ b/p2p/host/basic/basic_host_test.go
@@ -171,9 +171,9 @@ func TestProtocolHandlerEvents(t *testing.T) {
 		}
 	}
 
-	h.SetStreamHandler(protocol.TestingID, func(s network.Stream) {})
+	h.SetStreamHandler(protocol.TestingID, func(_ network.Stream) {})
 	assert([]protocol.ID{protocol.TestingID}, nil)
-	h.SetStreamHandler("foo", func(s network.Stream) {})
+	h.SetStreamHandler("foo", func(_ network.Stream) {})
 	assert([]protocol.ID{"foo"}, nil)
 	h.RemoveStreamHandler(protocol.TestingID)
 	assert(nil, []protocol.ID{protocol.TestingID})
@@ -181,7 +181,7 @@ func TestProtocolHandlerEvents(t *testing.T) {
 
 func TestHostAddrsFactory(t *testing.T) {
 	maddr := ma.StringCast("/ip4/1.2.3.4/tcp/1234")
-	addrsFactory := func(addrs []ma.Multiaddr) []ma.Multiaddr {
+	addrsFactory := func(_ []ma.Multiaddr) []ma.Multiaddr {
 		return []ma.Multiaddr{maddr}
 	}
 
@@ -242,7 +242,7 @@ func TestAllAddrsUnique(t *testing.T) {
 	}()
 	sendNewAddrs := make(chan struct{})
 	opts := HostOpts{
-		AddrsFactory: func(addrs []ma.Multiaddr) []ma.Multiaddr {
+		AddrsFactory: func(_ []ma.Multiaddr) []ma.Multiaddr {
 			select {
 			case <-sendNewAddrs:
 				return []ma.Multiaddr{
@@ -708,7 +708,7 @@ func TestHostAddrChangeDetection(t *testing.T) {
 
 	var lk sync.Mutex
 	currentAddrSet := 0
-	addrsFactory := func(addrs []ma.Multiaddr) []ma.Multiaddr {
+	addrsFactory := func(_ []ma.Multiaddr) []ma.Multiaddr {
 		lk.Lock()
 		defer lk.Unlock()
 		return addrSets[currentAddrSet]
diff --git a/p2p/host/basic/natmgr_test.go b/p2p/host/basic/natmgr_test.go
index c216e4f6..be2567dd 100644
--- a/p2p/host/basic/natmgr_test.go
+++ b/p2p/host/basic/natmgr_test.go
@@ -20,7 +20,7 @@ func setupMockNAT(t *testing.T) (mockNAT *MockNAT, reset func()) {
 	ctrl := gomock.NewController(t)
 	mockNAT = NewMockNAT(ctrl)
 	origDiscoverNAT := discoverNAT
-	discoverNAT = func(ctx context.Context) (nat, error) { return mockNAT, nil }
+	discoverNAT = func(_ context.Context) (nat, error) { return mockNAT, nil }
 	return mockNAT, func() {
 		discoverNAT = origDiscoverNAT
 		ctrl.Finish()
diff --git a/p2p/host/peerstore/pstoreds/ds_test.go b/p2p/host/peerstore/pstoreds/ds_test.go
index 1fada7b5..a240de3a 100644
--- a/p2p/host/peerstore/pstoreds/ds_test.go
+++ b/p2p/host/peerstore/pstoreds/ds_test.go
@@ -14,7 +14,7 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
-func mapDBStore(tb testing.TB) (ds.Batching, func()) {
+func mapDBStore(_ testing.TB) (ds.Batching, func()) {
 	store := ds.NewMapDatastore()
 	closer := func() {
 		store.Close()
diff --git a/p2p/host/peerstore/test/addr_book_suite.go b/p2p/host/peerstore/test/addr_book_suite.go
index 27a74d96..85929ad7 100644
--- a/p2p/host/peerstore/test/addr_book_suite.go
+++ b/p2p/host/peerstore/test/addr_book_suite.go
@@ -162,7 +162,7 @@ func testAddAddress(ab pstore.AddrBook, clk *mockClock.Mock) func(*testing.T) {
 	}
 }
 
-func testClearWorks(ab pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
+func testClearWorks(ab pstore.AddrBook, _ *mockClock.Mock) func(t *testing.T) {
 	return func(t *testing.T) {
 		ids := GeneratePeerIDs(2)
 		addrs := GenerateAddrs(5)
@@ -183,7 +183,7 @@ func testClearWorks(ab pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T)
 	}
 }
 
-func testSetNegativeTTLClears(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
+func testSetNegativeTTLClears(m pstore.AddrBook, _ *mockClock.Mock) func(t *testing.T) {
 	return func(t *testing.T) {
 		id := GeneratePeerIDs(1)[0]
 		addrs := GenerateAddrs(100)
@@ -229,7 +229,7 @@ func testSetNegativeTTLClears(m pstore.AddrBook, clk *mockClock.Mock) func(t *te
 
 func testUpdateTTLs(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
 	return func(t *testing.T) {
-		t.Run("update ttl of peer with no addrs", func(t *testing.T) {
+		t.Run("update ttl of peer with no addrs", func(_ *testing.T) {
 			id := GeneratePeerIDs(1)[0]
 
 			// Shouldn't panic.
@@ -293,8 +293,8 @@ func testUpdateTTLs(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
 	}
 }
 
-func testNilAddrsDontBreak(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
-	return func(t *testing.T) {
+func testNilAddrsDontBreak(m pstore.AddrBook, _ *mockClock.Mock) func(t *testing.T) {
+	return func(_ *testing.T) {
 		id := GeneratePeerIDs(1)[0]
 
 		m.SetAddr(id, nil, time.Hour)
@@ -347,7 +347,7 @@ func testAddressesExpire(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing
 	}
 }
 
-func testClearWithIterator(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
+func testClearWithIterator(m pstore.AddrBook, _ *mockClock.Mock) func(t *testing.T) {
 	return func(t *testing.T) {
 		ids := GeneratePeerIDs(2)
 		addrs := GenerateAddrs(100)
@@ -374,7 +374,7 @@ func testClearWithIterator(m pstore.AddrBook, clk *mockClock.Mock) func(t *testi
 	}
 }
 
-func testPeersWithAddrs(m pstore.AddrBook, clk *mockClock.Mock) func(t *testing.T) {
+func testPeersWithAddrs(m pstore.AddrBook, _ *mockClock.Mock) func(t *testing.T) {
 	return func(t *testing.T) {
 		// cannot run in parallel as the store is modified.
 		// go runs sequentially in the specified order
diff --git a/p2p/host/peerstore/test/benchmarks_suite.go b/p2p/host/peerstore/test/benchmarks_suite.go
index 01669a1b..63446c16 100644
--- a/p2p/host/peerstore/test/benchmarks_suite.go
+++ b/p2p/host/peerstore/test/benchmarks_suite.go
@@ -7,7 +7,7 @@ import (
 	pstore "github.com/libp2p/go-libp2p/core/peerstore"
 )
 
-func BenchmarkPeerstore(b *testing.B, factory PeerstoreFactory, variant string) {
+func BenchmarkPeerstore(b *testing.B, factory PeerstoreFactory, _ string) {
 	for _, sz := range []int{1, 10, 100} {
 		const N = 10000
 		peers := getPeerPairs(b, N, sz)
diff --git a/p2p/host/pstoremanager/pstoremanager_test.go b/p2p/host/pstoremanager/pstoremanager_test.go
index 9321031c..58963c57 100644
--- a/p2p/host/pstoremanager/pstoremanager_test.go
+++ b/p2p/host/pstoremanager/pstoremanager_test.go
@@ -33,7 +33,7 @@ func TestGracePeriod(t *testing.T) {
 	require.NoError(t, err)
 	start := time.Now()
 	removed := make(chan struct{})
-	pstore.EXPECT().RemovePeer(peer.ID("foobar")).DoAndReturn(func(p peer.ID) {
+	pstore.EXPECT().RemovePeer(peer.ID("foobar")).DoAndReturn(func(_ peer.ID) {
 		defer close(removed)
 		// make sure the call happened after the grace period
 		require.GreaterOrEqual(t, time.Since(start), gracePeriod)
diff --git a/p2p/http/auth/auth_test.go b/p2p/http/auth/auth_test.go
index 293f70de..c7e41745 100644
--- a/p2p/http/auth/auth_test.go
+++ b/p2p/http/auth/auth_test.go
@@ -250,7 +250,7 @@ func TestConcurrentAuth(t *testing.T) {
 		},
 		TokenTTL: time.Hour,
 		NoTLS:    true,
-		Next: func(peer peer.ID, w http.ResponseWriter, r *http.Request) {
+		Next: func(_ peer.ID, w http.ResponseWriter, r *http.Request) {
 			reqBody, err := io.ReadAll(r.Body)
 			require.NoError(t, err)
 			_, err = w.Write(reqBody)
diff --git a/p2p/http/auth/internal/handshake/handshake_test.go b/p2p/http/auth/internal/handshake/handshake_test.go
index 0579b951..ce22cd0b 100644
--- a/p2p/http/auth/internal/handshake/handshake_test.go
+++ b/p2p/http/auth/internal/handshake/handshake_test.go
@@ -318,7 +318,7 @@ func FuzzServerHandshakeNoPanic(f *testing.F) {
 	zeroBytes := [32]byte{}
 	hmac := hmac.New(sha256.New, zeroBytes[:])
 
-	f.Fuzz(func(t *testing.T, data []byte) {
+	f.Fuzz(func(_ *testing.T, data []byte) {
 		hmac.Reset()
 		h := PeerIDAuthHandshakeServer{
 			Hostname: "example.com",
@@ -380,7 +380,7 @@ func BenchmarkOpaqueStateRead(b *testing.B) {
 func FuzzParsePeerIDAuthSchemeParamsNoPanic(f *testing.F) {
 	p := params{}
 	// Just check that we don't panic
-	f.Fuzz(func(t *testing.T, data []byte) {
+	f.Fuzz(func(_ *testing.T, data []byte) {
 		p.parsePeerIDAuthSchemeParams(data)
 	})
 }
diff --git a/p2p/http/example_test.go b/p2p/http/example_test.go
index 3b833410..e77b3339 100644
--- a/p2p/http/example_test.go
+++ b/p2p/http/example_test.go
@@ -181,7 +181,7 @@ func ExampleHost_overLibp2pStreams() {
 	// Make an HTTP request using the Go standard library, but over libp2p
 	// streams. If the server were listening on an HTTP transport, this could
 	// also make the request over the HTTP transport.
-	httpClient, err := client.NamespacedClient("/echo/1.0.0", peer.AddrInfo{ID: server.PeerID(), Addrs: server.Addrs()})
+	httpClient, _ := client.NamespacedClient("/echo/1.0.0", peer.AddrInfo{ID: server.PeerID(), Addrs: server.Addrs()})
 
 	// Only need to Post to "/" because this client is namespaced to the "/echo/1.0.0" protocol.
 	resp, err := httpClient.Post("/", "application/octet-stream", strings.NewReader("Hello HTTP"))
@@ -225,7 +225,7 @@ func ExampleHost_SetHTTPHandler() {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}))
@@ -259,7 +259,7 @@ func ExampleHost_SetHTTPHandlerAtPath() {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	server.SetHTTPHandlerAtPath("/hello/1", "/other-place/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandlerAtPath("/hello/1", "/other-place/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}))
@@ -296,7 +296,7 @@ func ExampleHost_NamespacedClient() {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	server.SetHTTPHandlerAtPath("/hello/1", "/other-place/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandlerAtPath("/hello/1", "/other-place/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}))
@@ -334,7 +334,7 @@ func ExampleHost_NamespaceRoundTripper() {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}))
@@ -378,7 +378,7 @@ func ExampleHost_NewConstrainedRoundTripper() {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandler("/hello/1", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}))
@@ -446,7 +446,7 @@ func ExampleHost_RoundTrip() {
 	}
 	go server.Serve()
 	defer server.Close()
-	server.SetHTTPHandlerAtPath("/hello/", "/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	server.SetHTTPHandlerAtPath("/hello/", "/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("Hello World"))
 	}))
 
diff --git a/p2p/http/libp2phttp_test.go b/p2p/http/libp2phttp_test.go
index c87c9a3a..5737c28c 100644
--- a/p2p/http/libp2phttp_test.go
+++ b/p2p/http/libp2phttp_test.go
@@ -44,7 +44,7 @@ func TestHTTPOverStreams(t *testing.T) {
 
 	httpHost := libp2phttp.Host{StreamHost: serverHost}
 
-	httpHost.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	httpHost.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
@@ -124,7 +124,7 @@ func TestHTTPOverStreamsContextAndClientTimeout(t *testing.T) {
 	require.NoError(t, err)
 
 	httpHost := libp2phttp.Host{StreamHost: serverHost}
-	httpHost.SetHTTPHandler("/hello/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	httpHost.SetHTTPHandler("/hello/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		time.Sleep(2 * clientTimeout)
 		w.Write([]byte("hello"))
 	}))
@@ -180,7 +180,7 @@ func TestHTTPOverStreamsReturnsConnectionClose(t *testing.T) {
 
 	httpHost := libp2phttp.Host{StreamHost: serverHost}
 
-	httpHost.SetHTTPHandlerAtPath("/hello", "/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	httpHost.SetHTTPHandlerAtPath("/hello", "/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
@@ -222,7 +222,7 @@ func TestRoundTrippers(t *testing.T) {
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
 
-	httpHost.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	httpHost.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
@@ -240,7 +240,7 @@ func TestRoundTrippers(t *testing.T) {
 	}{
 		{
 			name: "HTTP preferred",
-			setupRoundTripper: func(t *testing.T, clientStreamHost host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
+			setupRoundTripper: func(t *testing.T, _ host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
 				rt, err := clientHTTPHost.NewConstrainedRoundTripper(peer.AddrInfo{
 					ID:    serverHost.ID(),
 					Addrs: serverMultiaddrs,
@@ -251,7 +251,7 @@ func TestRoundTrippers(t *testing.T) {
 		},
 		{
 			name: "HTTP first",
-			setupRoundTripper: func(t *testing.T, clientStreamHost host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
+			setupRoundTripper: func(t *testing.T, _ host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
 				rt, err := clientHTTPHost.NewConstrainedRoundTripper(peer.AddrInfo{
 					ID:    serverHost.ID(),
 					Addrs: []ma.Multiaddr{serverHTTPAddr, serverHost.Addrs()[0]},
@@ -262,7 +262,7 @@ func TestRoundTrippers(t *testing.T) {
 		},
 		{
 			name: "No HTTP transport",
-			setupRoundTripper: func(t *testing.T, clientStreamHost host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
+			setupRoundTripper: func(t *testing.T, _ host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
 				rt, err := clientHTTPHost.NewConstrainedRoundTripper(peer.AddrInfo{
 					ID:    serverHost.ID(),
 					Addrs: []ma.Multiaddr{serverHost.Addrs()[0]},
@@ -274,7 +274,7 @@ func TestRoundTrippers(t *testing.T) {
 		},
 		{
 			name: "Stream transport first",
-			setupRoundTripper: func(t *testing.T, clientStreamHost host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
+			setupRoundTripper: func(t *testing.T, _ host.Host, clientHTTPHost *libp2phttp.Host) http.RoundTripper {
 				rt, err := clientHTTPHost.NewConstrainedRoundTripper(peer.AddrInfo{
 					ID:    serverHost.ID(),
 					Addrs: []ma.Multiaddr{serverHost.Addrs()[0], serverHTTPAddr},
@@ -402,7 +402,7 @@ func TestPlainOldHTTPServer(t *testing.T) {
 		},
 		{
 			name: "using stock http client",
-			do: func(t *testing.T, request *http.Request) (*http.Response, error) {
+			do: func(_ *testing.T, request *http.Request) (*http.Response, error) {
 				request.URL.Scheme = "http"
 				request.URL.Host = l.Addr().String()
 				request.Host = l.Addr().String()
@@ -456,7 +456,7 @@ func TestHostZeroValue(t *testing.T) {
 		InsecureAllowHTTP: true,
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/0/http")},
 	}
-	server.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello")) }))
+	server.SetHTTPHandler("/hello", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Write([]byte("hello")) }))
 	go func() {
 		server.Serve()
 	}()
@@ -564,7 +564,7 @@ func TestCustomServeMux(t *testing.T) {
 }
 
 func TestSetHandlerAtPath(t *testing.T) {
-	hf := func(w http.ResponseWriter, r *http.Request) {
+	hf := func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Add("Content-Type", "text/plain")
 		w.Write([]byte("Hello World"))
 	}
@@ -733,7 +733,7 @@ func TestResponseWriterShouldNotHaveCancelledContext(t *testing.T) {
 	defer httpHost.Close()
 
 	closeNotifyCh := make(chan bool, 1)
-	httpHost.SetHTTPHandlerAtPath("/test", "/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	httpHost.SetHTTPHandlerAtPath("/test", "/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		// Legacy code uses this to check if the connection was closed
 		//lint:ignore SA1019 This is a test to assert we do the right thing since Go HTTP stdlib depends on this.
 		ch := w.(http.CloseNotifier).CloseNotify()
@@ -781,7 +781,7 @@ func TestHTTPHostAsRoundTripper(t *testing.T) {
 	}))
 
 	// Different protocol.ID and mounted at a different path
-	serverHttpHost.SetHTTPHandlerAtPath("/hello-again", "/hello2", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/hello-again", "/hello2", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
@@ -844,30 +844,30 @@ func TestRedirects(t *testing.T) {
 	go serverHttpHost.Serve()
 	defer serverHttpHost.Close()
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/a", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/a", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Set("Location", "/b/")
 		w.WriteHeader(http.StatusMovedPermanently)
 	}))
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-2/0.0.1", "/b", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-2/0.0.1", "/b", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Set("Location", "/c/")
 		w.WriteHeader(http.StatusMovedPermanently)
 	}))
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-3/0.0.1", "/c", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-3/0.0.1", "/c", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Set("Location", "/d/")
 		w.WriteHeader(http.StatusMovedPermanently)
 	}))
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-4/0.0.1", "/d", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-4/0.0.1", "/d", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/foo/bar/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/foo/bar/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Set("Location", "../baz/")
 		w.WriteHeader(http.StatusMovedPermanently)
 	}))
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/foo/baz/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/foo/baz/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Write([]byte("hello"))
 	}))
 
@@ -945,12 +945,12 @@ func TestMultiaddrURIRedirect(t *testing.T) {
 	require.NotNil(t, streamMultiaddr)
 
 	// Redirect to a whole other transport!
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/a", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-1/0.0.1", "/a", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.Header().Set("Location", fmt.Sprintf("multiaddr:%s/p2p/%s/http-path/b", streamMultiaddr, serverHost.ID()))
 		w.WriteHeader(http.StatusMovedPermanently)
 	}))
 
-	serverHttpHost.SetHTTPHandlerAtPath("/redirect-2/0.0.1", "/b", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+	serverHttpHost.SetHTTPHandlerAtPath("/redirect-2/0.0.1", "/b", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
 		w.WriteHeader(http.StatusOK)
 	}))
 
diff --git a/p2p/net/connmgr/connmgr_test.go b/p2p/net/connmgr/connmgr_test.go
index f47557b0..e8e61914 100644
--- a/p2p/net/connmgr/connmgr_test.go
+++ b/p2p/net/connmgr/connmgr_test.go
@@ -36,7 +36,7 @@ func (c *tconn) Close() error {
 	return nil
 }
 
-func (c *tconn) CloseWithError(code network.ConnErrorCode) error {
+func (c *tconn) CloseWithError(_ network.ConnErrorCode) error {
 	atomic.StoreUint32(&c.closed, 1)
 	if c.disconnectNotify != nil {
 		c.disconnectNotify(nil, c)
@@ -531,7 +531,7 @@ func TestPeerProtectionSingleTag(t *testing.T) {
 	}
 
 	// protect the first 5 peers.
-	var protected []network.Conn
+	protected := make([]network.Conn, 0, 5)
 	for _, c := range conns[0:5] {
 		cm.Protect(c.RemotePeer(), "global")
 		protected = append(protected, c)
@@ -610,7 +610,7 @@ func TestPeerProtectionMultipleTags(t *testing.T) {
 	}
 
 	// protect the first 5 peers under two tags.
-	var protected []network.Conn
+	protected := make([]network.Conn, 0, 5)
 	for _, c := range conns[0:5] {
 		cm.Protect(c.RemotePeer(), "tag1")
 		cm.Protect(c.RemotePeer(), "tag2")
@@ -804,20 +804,20 @@ type mockConn struct {
 	stats network.ConnStats
 }
 
-func (m mockConn) Close() error                                          { panic("implement me") }
-func (m mockConn) CloseWithError(errCode network.ConnErrorCode) error    { panic("implement me") }
-func (m mockConn) LocalPeer() peer.ID                                    { panic("implement me") }
-func (m mockConn) RemotePeer() peer.ID                                   { panic("implement me") }
-func (m mockConn) RemotePublicKey() crypto.PubKey                        { panic("implement me") }
-func (m mockConn) LocalMultiaddr() ma.Multiaddr                          { panic("implement me") }
-func (m mockConn) RemoteMultiaddr() ma.Multiaddr                         { panic("implement me") }
-func (m mockConn) Stat() network.ConnStats                               { return m.stats }
-func (m mockConn) ID() string                                            { panic("implement me") }
-func (m mockConn) IsClosed() bool                                        { panic("implement me") }
-func (m mockConn) NewStream(ctx context.Context) (network.Stream, error) { panic("implement me") }
-func (m mockConn) GetStreams() []network.Stream                          { panic("implement me") }
-func (m mockConn) Scope() network.ConnScope                              { panic("implement me") }
-func (m mockConn) ConnState() network.ConnectionState                    { return network.ConnectionState{} }
+func (m mockConn) Close() error                                        { panic("implement me") }
+func (m mockConn) CloseWithError(_ network.ConnErrorCode) error        { panic("implement me") }
+func (m mockConn) LocalPeer() peer.ID                                  { panic("implement me") }
+func (m mockConn) RemotePeer() peer.ID                                 { panic("implement me") }
+func (m mockConn) RemotePublicKey() crypto.PubKey                      { panic("implement me") }
+func (m mockConn) LocalMultiaddr() ma.Multiaddr                        { panic("implement me") }
+func (m mockConn) RemoteMultiaddr() ma.Multiaddr                       { panic("implement me") }
+func (m mockConn) Stat() network.ConnStats                             { return m.stats }
+func (m mockConn) ID() string                                          { panic("implement me") }
+func (m mockConn) IsClosed() bool                                      { panic("implement me") }
+func (m mockConn) NewStream(_ context.Context) (network.Stream, error) { panic("implement me") }
+func (m mockConn) GetStreams() []network.Stream                        { panic("implement me") }
+func (m mockConn) Scope() network.ConnScope                            { panic("implement me") }
+func (m mockConn) ConnState() network.ConnectionState                  { return network.ConnectionState{} }
 
 func makeSegmentsWithPeerInfos(peerInfos peerInfos) *segments {
 	var s = func() *segments {
diff --git a/p2p/net/mock/mock_notif_test.go b/p2p/net/mock/mock_notif_test.go
index 600e0af2..713e0a5d 100644
--- a/p2p/net/mock/mock_notif_test.go
+++ b/p2p/net/mock/mock_notif_test.go
@@ -191,15 +191,15 @@ func newNetNotifiee(t *testing.T, buffer int) *netNotifiee {
 	return nn
 }
 
-func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr) {
+func (nn *netNotifiee) Listen(_ network.Network, a ma.Multiaddr) {
 	nn.listen <- a
 }
-func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {
+func (nn *netNotifiee) ListenClose(_ network.Network, a ma.Multiaddr) {
 	nn.listenClose <- a
 }
-func (nn *netNotifiee) Connected(n network.Network, v network.Conn) {
+func (nn *netNotifiee) Connected(_ network.Network, v network.Conn) {
 	nn.connected <- v
 }
-func (nn *netNotifiee) Disconnected(n network.Network, v network.Conn) {
+func (nn *netNotifiee) Disconnected(_ network.Network, v network.Conn) {
 	nn.disconnected <- v
 }
diff --git a/p2p/net/nat/nat_test.go b/p2p/net/nat/nat_test.go
index 5779a27e..9e19f8ea 100644
--- a/p2p/net/nat/nat_test.go
+++ b/p2p/net/nat/nat_test.go
@@ -20,7 +20,7 @@ func setupMockNAT(t *testing.T) (mockNAT *MockNAT, reset func()) {
 	mockNAT = NewMockNAT(ctrl)
 	mockNAT.EXPECT().GetDeviceAddress().Return(nil, errors.New("nope")) // is only used for logging
 	origDiscoverGateway := discoverGateway
-	discoverGateway = func(ctx context.Context) (nat.NAT, error) { return mockNAT, nil }
+	discoverGateway = func(_ context.Context) (nat.NAT, error) { return mockNAT, nil }
 	return mockNAT, func() {
 		discoverGateway = origDiscoverGateway
 		ctrl.Finish()
diff --git a/p2p/net/pnet/psk_conn_test.go b/p2p/net/pnet/psk_conn_test.go
index 3faac973..b3310656 100644
--- a/p2p/net/pnet/psk_conn_test.go
+++ b/p2p/net/pnet/psk_conn_test.go
@@ -8,7 +8,7 @@ import (
 	"testing"
 )
 
-func setupPSKConns(ctx context.Context, t *testing.T) (net.Conn, net.Conn) {
+func setupPSKConns(_ context.Context, t *testing.T) (net.Conn, net.Conn) {
 	testPSK := make([]byte, 32) // null bytes are as good test key as any other key
 	conn1, conn2 := net.Pipe()
 
diff --git a/p2p/net/reuseport/transport_test.go b/p2p/net/reuseport/transport_test.go
index 92ccf170..c46d3a1f 100644
--- a/p2p/net/reuseport/transport_test.go
+++ b/p2p/net/reuseport/transport_test.go
@@ -207,7 +207,7 @@ func TestGlobalToGlobal(t *testing.T) {
 	testUseFirst(t, globalV6, globalV6, loopbackV6)
 }
 
-func testUseFirst(t *testing.T, listen, use, never ma.Multiaddr) {
+func testUseFirst(t *testing.T, _, _, _ ma.Multiaddr) {
 	var trA Transport
 	var trB Transport
 	listenerA, err := trA.Listen(globalV4)
diff --git a/p2p/net/swarm/black_hole_detector_test.go b/p2p/net/swarm/black_hole_detector_test.go
index e596970a..1d59eb54 100644
--- a/p2p/net/swarm/black_hole_detector_test.go
+++ b/p2p/net/swarm/black_hole_detector_test.go
@@ -11,9 +11,8 @@ import (
 func TestBlackHoleSuccessCounterReset(t *testing.T) {
 	n := 10
 	bhf := &BlackHoleSuccessCounter{N: n, MinSuccesses: 2, Name: "test"}
-	var i = 0
 	// calls up to n should be probing
-	for i = 1; i <= n; i++ {
+	for i := 1; i <= n; i++ {
 		if bhf.HandleRequest() != blackHoleStateProbing {
 			t.Fatalf("expected calls up to n to be probes")
 		}
@@ -24,7 +23,7 @@ func TestBlackHoleSuccessCounterReset(t *testing.T) {
 	}
 
 	// after threshold calls every nth call should be a probe
-	for i = n + 1; i < 42; i++ {
+	for i := n + 1; i < 42; i++ {
 		result := bhf.HandleRequest()
 		if (i%n == 0 && result != blackHoleStateProbing) || (i%n != 0 && result != blackHoleStateBlocked) {
 			t.Fatalf("expected every nth dial to be a probe")
@@ -36,7 +35,7 @@ func TestBlackHoleSuccessCounterReset(t *testing.T) {
 
 	bhf.RecordResult(true)
 	// check if calls up to n are probes again
-	for i = 0; i < n; i++ {
+	for i := 0; i < n; i++ {
 		if bhf.HandleRequest() != blackHoleStateProbing {
 			t.Fatalf("expected black hole detector state to reset after success")
 		}
diff --git a/p2p/net/swarm/dial_sync_test.go b/p2p/net/swarm/dial_sync_test.go
index d7131a21..e44e3317 100644
--- a/p2p/net/swarm/dial_sync_test.go
+++ b/p2p/net/swarm/dial_sync_test.go
@@ -17,7 +17,7 @@ func getMockDialFunc() (dialWorkerFunc, func(), context.Context, <-chan struct{}
 	dfcalls := make(chan struct{}, 512) // buffer it large enough that we won't care
 	dialctx, cancel := context.WithCancel(context.Background())
 	ch := make(chan struct{})
-	f := func(p peer.ID, reqch <-chan dialRequest) {
+	f := func(_ peer.ID, reqch <-chan dialRequest) {
 		defer cancel()
 		dfcalls <- struct{}{}
 		go func() {
@@ -164,7 +164,7 @@ func TestDialSyncAllCancel(t *testing.T) {
 func TestFailFirst(t *testing.T) {
 	var handledFirst atomic.Bool
 	dialErr := fmt.Errorf("gophers ate the modem")
-	f := func(p peer.ID, reqch <-chan dialRequest) {
+	f := func(_ peer.ID, reqch <-chan dialRequest) {
 		go func() {
 			for {
 				req, ok := <-reqch
@@ -195,8 +195,8 @@ func TestFailFirst(t *testing.T) {
 	require.NotNil(t, c, "should have gotten a 'real' conn back")
 }
 
-func TestStressActiveDial(t *testing.T) {
-	ds := newDialSync(func(p peer.ID, reqch <-chan dialRequest) {
+func TestStressActiveDial(_ *testing.T) {
+	ds := newDialSync(func(_ peer.ID, reqch <-chan dialRequest) {
 		go func() {
 			for {
 				req, ok := <-reqch
diff --git a/p2p/net/swarm/dial_worker_test.go b/p2p/net/swarm/dial_worker_test.go
index c7298fb6..db2981fe 100644
--- a/p2p/net/swarm/dial_worker_test.go
+++ b/p2p/net/swarm/dial_worker_test.go
@@ -743,7 +743,7 @@ loop:
 // makeRanker takes a slice of timedDial objects and returns a DialRanker
 // which will trigger dials to addresses at the specified delays in the timedDials
 func makeRanker(tc []timedDial) network.DialRanker {
-	return func(addrs []ma.Multiaddr) []network.AddrDelay {
+	return func(_ []ma.Multiaddr) []network.AddrDelay {
 		res := make([]network.AddrDelay, len(tc))
 		for i := 0; i < len(tc); i++ {
 			res[i] = network.AddrDelay{Addr: tc[i].addr, Delay: tc[i].delay}
@@ -1104,7 +1104,7 @@ func TestDialWorkerLoopTCPConnUpgradeWait(t *testing.T) {
 	s1.Peerstore().AddAddrs(s2.LocalPeer(), []ma.Multiaddr{a1, a2}, peerstore.PermanentAddrTTL)
 
 	rankerCalled := make(chan struct{})
-	s1.dialRanker = func(addrs []ma.Multiaddr) []network.AddrDelay {
+	s1.dialRanker = func(_ []ma.Multiaddr) []network.AddrDelay {
 		defer close(rankerCalled)
 		return []network.AddrDelay{{Addr: a1, Delay: 0}, {Addr: a2, Delay: 100 * time.Millisecond}}
 	}
diff --git a/p2p/net/swarm/limiter_test.go b/p2p/net/swarm/limiter_test.go
index 8e61958c..7a1772ba 100644
--- a/p2p/net/swarm/limiter_test.go
+++ b/p2p/net/swarm/limiter_test.go
@@ -51,7 +51,7 @@ func tryDialAddrs(ctx context.Context, l *dialLimiter, p peer.ID, addrs []ma.Mul
 }
 
 func hangDialFunc(hang chan struct{}) dialfunc {
-	return func(ctx context.Context, p peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
+	return func(_ context.Context, _ peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
 		if mafmt.UTP.Matches(a) {
 			return transport.CapableConn(nil), nil
 		}
@@ -188,7 +188,7 @@ func TestFDLimiting(t *testing.T) {
 func TestTokenRedistribution(t *testing.T) {
 	var lk sync.Mutex
 	hangchs := make(map[peer.ID]chan struct{})
-	df := func(ctx context.Context, p peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
+	df := func(_ context.Context, p peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
 		if tcpPortOver(a, 10) {
 			return (transport.CapableConn)(nil), nil
 		}
@@ -281,7 +281,7 @@ func TestTokenRedistribution(t *testing.T) {
 }
 
 func TestStressLimiter(t *testing.T) {
-	df := func(ctx context.Context, p peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
+	df := func(_ context.Context, _ peer.ID, a ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
 		if tcpPortOver(a, 1000) {
 			return transport.CapableConn(nil), nil
 		}
@@ -335,7 +335,7 @@ func TestStressLimiter(t *testing.T) {
 }
 
 func TestFDLimitUnderflow(t *testing.T) {
-	df := func(ctx context.Context, p peer.ID, addr ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
+	df := func(ctx context.Context, _ peer.ID, _ ma.Multiaddr, _ chan<- transport.DialUpdate) (transport.CapableConn, error) {
 		select {
 		case <-ctx.Done():
 		case <-time.After(5 * time.Second):
diff --git a/p2p/net/swarm/swarm_notif_test.go b/p2p/net/swarm/swarm_notif_test.go
index 1d0b4cf8..e6fb1698 100644
--- a/p2p/net/swarm/swarm_notif_test.go
+++ b/p2p/net/swarm/swarm_notif_test.go
@@ -171,15 +171,15 @@ func newNetNotifiee(buffer int) *netNotifiee {
 	}
 }
 
-func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr) {
+func (nn *netNotifiee) Listen(_ network.Network, a ma.Multiaddr) {
 	nn.listen <- a
 }
-func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {
+func (nn *netNotifiee) ListenClose(_ network.Network, a ma.Multiaddr) {
 	nn.listenClose <- a
 }
-func (nn *netNotifiee) Connected(n network.Network, v network.Conn) {
+func (nn *netNotifiee) Connected(_ network.Network, v network.Conn) {
 	nn.connected <- v
 }
-func (nn *netNotifiee) Disconnected(n network.Network, v network.Conn) {
+func (nn *netNotifiee) Disconnected(_ network.Network, v network.Conn) {
 	nn.disconnected <- v
 }
diff --git a/p2p/net/swarm/swarm_test.go b/p2p/net/swarm/swarm_test.go
index 172ac3d8..c911d5ee 100644
--- a/p2p/net/swarm/swarm_test.go
+++ b/p2p/net/swarm/swarm_test.go
@@ -249,7 +249,7 @@ func TestConnectionGating(t *testing.T) {
 		},
 		"p1 gates outbound peer dial": {
 			p1Gater: func(c *MockConnectionGater) *MockConnectionGater {
-				c.PeerDial = func(p peer.ID) bool { return false }
+				c.PeerDial = func(_ peer.ID) bool { return false }
 				return c
 			},
 			p1ConnectednessToP2: network.NotConnected,
@@ -258,7 +258,7 @@ func TestConnectionGating(t *testing.T) {
 		},
 		"p1 gates outbound addr dialing": {
 			p1Gater: func(c *MockConnectionGater) *MockConnectionGater {
-				c.Dial = func(p peer.ID, addr ma.Multiaddr) bool { return false }
+				c.Dial = func(_ peer.ID, _ ma.Multiaddr) bool { return false }
 				return c
 			},
 			p1ConnectednessToP2: network.NotConnected,
@@ -276,7 +276,7 @@ func TestConnectionGating(t *testing.T) {
 		},
 		"p2 gates inbound peer dial before securing": {
 			p2Gater: func(c *MockConnectionGater) *MockConnectionGater {
-				c.Accept = func(c network.ConnMultiaddrs) bool { return false }
+				c.Accept = func(_ network.ConnMultiaddrs) bool { return false }
 				return c
 			},
 			p1ConnectednessToP2: network.NotConnected,
@@ -296,7 +296,7 @@ func TestConnectionGating(t *testing.T) {
 		},
 		"p2 gates inbound peer dial after upgrading": {
 			p1Gater: func(c *MockConnectionGater) *MockConnectionGater {
-				c.Upgraded = func(c network.Conn) (bool, control.DisconnectReason) { return false, 0 }
+				c.Upgraded = func(_ network.Conn) (bool, control.DisconnectReason) { return false, 0 }
 				return c
 			},
 			p1ConnectednessToP2: network.NotConnected,
@@ -305,7 +305,7 @@ func TestConnectionGating(t *testing.T) {
 		},
 		"p2 gates outbound dials": {
 			p2Gater: func(c *MockConnectionGater) *MockConnectionGater {
-				c.PeerDial = func(p peer.ID) bool { return false }
+				c.PeerDial = func(_ peer.ID) bool { return false }
 				return c
 			},
 			p1ConnectednessToP2: network.Connected,
@@ -521,7 +521,7 @@ func TestResourceManagerAcceptStream(t *testing.T) {
 	rcmgr2 := mocknetwork.NewMockResourceManager(ctrl)
 	s2 := GenSwarm(t, WithSwarmOpts(swarm.WithResourceManager(rcmgr2)))
 	defer s2.Close()
-	s2.SetStreamHandler(func(str network.Stream) { t.Fatal("didn't expect to accept a stream") })
+	s2.SetStreamHandler(func(_ network.Stream) { t.Fatal("didn't expect to accept a stream") })
 
 	connectSwarms(t, context.Background(), []*swarm.Swarm{s1, s2})
 
diff --git a/p2p/net/swarm/testing/testing.go b/p2p/net/swarm/testing/testing.go
index 50ab3987..bafe49b7 100644
--- a/p2p/net/swarm/testing/testing.go
+++ b/p2p/net/swarm/testing/testing.go
@@ -270,15 +270,15 @@ type MockConnectionGater struct {
 
 func DefaultMockConnectionGater() *MockConnectionGater {
 	m := &MockConnectionGater{}
-	m.Dial = func(p peer.ID, addr ma.Multiaddr) bool {
+	m.Dial = func(_ peer.ID, _ ma.Multiaddr) bool {
 		return true
 	}
 
-	m.PeerDial = func(p peer.ID) bool {
+	m.PeerDial = func(_ peer.ID) bool {
 		return true
 	}
 
-	m.Accept = func(c network.ConnMultiaddrs) bool {
+	m.Accept = func(_ network.ConnMultiaddrs) bool {
 		return true
 	}
 
@@ -286,7 +286,7 @@ func DefaultMockConnectionGater() *MockConnectionGater {
 		return true
 	}
 
-	m.Upgraded = func(c network.Conn) (bool, control.DisconnectReason) {
+	m.Upgraded = func(_ network.Conn) (bool, control.DisconnectReason) {
 		return true, 0
 	}
 
diff --git a/p2p/net/swarm/transport_test.go b/p2p/net/swarm/transport_test.go
index fe743475..b19cb21e 100644
--- a/p2p/net/swarm/transport_test.go
+++ b/p2p/net/swarm/transport_test.go
@@ -19,15 +19,15 @@ type dummyTransport struct {
 	closed    bool
 }
 
-func (dt *dummyTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error) {
+func (dt *dummyTransport) Dial(_ context.Context, _ ma.Multiaddr, _ peer.ID) (transport.CapableConn, error) {
 	panic("unimplemented")
 }
 
-func (dt *dummyTransport) CanDial(addr ma.Multiaddr) bool {
+func (dt *dummyTransport) CanDial(_ ma.Multiaddr) bool {
 	panic("unimplemented")
 }
 
-func (dt *dummyTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error) {
+func (dt *dummyTransport) Listen(_ ma.Multiaddr) (transport.Listener, error) {
 	panic("unimplemented")
 }
 
diff --git a/p2p/net/upgrader/gater_test.go b/p2p/net/upgrader/gater_test.go
index 72b1d8fc..1f47d3f8 100644
--- a/p2p/net/upgrader/gater_test.go
+++ b/p2p/net/upgrader/gater_test.go
@@ -33,28 +33,28 @@ func (t *testGater) BlockSecured(block bool) {
 	t.blockSecured = block
 }
 
-func (t *testGater) InterceptPeerDial(p peer.ID) (allow bool) {
+func (t *testGater) InterceptPeerDial(_ peer.ID) (allow bool) {
 	panic("not implemented")
 }
 
-func (t *testGater) InterceptAddrDial(id peer.ID, multiaddr ma.Multiaddr) (allow bool) {
+func (t *testGater) InterceptAddrDial(_ peer.ID, _ ma.Multiaddr) (allow bool) {
 	panic("not implemented")
 }
 
-func (t *testGater) InterceptAccept(multiaddrs network.ConnMultiaddrs) (allow bool) {
+func (t *testGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool) {
 	t.Lock()
 	defer t.Unlock()
 
 	return !t.blockAccept
 }
 
-func (t *testGater) InterceptSecured(direction network.Direction, id peer.ID, multiaddrs network.ConnMultiaddrs) (allow bool) {
+func (t *testGater) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) {
 	t.Lock()
 	defer t.Unlock()
 
 	return !t.blockSecured
 }
 
-func (t *testGater) InterceptUpgraded(conn network.Conn) (allow bool, reason control.DisconnectReason) {
+func (t *testGater) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) {
 	panic("not implemented")
 }
diff --git a/p2p/net/upgrader/upgrader_test.go b/p2p/net/upgrader/upgrader_test.go
index 920ccaab..95fa49cb 100644
--- a/p2p/net/upgrader/upgrader_test.go
+++ b/p2p/net/upgrader/upgrader_test.go
@@ -99,7 +99,7 @@ type errorMuxer struct{}
 
 var _ network.Multiplexer = &errorMuxer{}
 
-func (m *errorMuxer) NewConn(c net.Conn, isServer bool, scope network.PeerScope) (network.MuxedConn, error) {
+func (m *errorMuxer) NewConn(_ net.Conn, _ bool, _ network.PeerScope) (network.MuxedConn, error) {
 	return nil, errors.New("mux error")
 }
 
diff --git a/p2p/protocol/autonatv2/server_test.go b/p2p/protocol/autonatv2/server_test.go
index 7447fc8a..fb50b3a5 100644
--- a/p2p/protocol/autonatv2/server_test.go
+++ b/p2p/protocol/autonatv2/server_test.go
@@ -194,7 +194,7 @@ func TestServerMaxConcurrentRequestsPerPeer(t *testing.T) {
 	stallChan := make(chan struct{})
 	an := newAutoNAT(t, nil, allowPrivateAddrs, withDataRequestPolicy(
 		// stall all allowed requests
-		func(_, dialAddr ma.Multiaddr) bool {
+		func(_, _ ma.Multiaddr) bool {
 			<-stallChan
 			return true
 		}),
@@ -624,7 +624,7 @@ func FuzzServerDialRequest(f *testing.F) {
 }
 
 func FuzzReadDialData(f *testing.F) {
-	f.Fuzz(func(t *testing.T, numBytes int, data []byte) {
+	f.Fuzz(func(_ *testing.T, numBytes int, data []byte) {
 		readDialData(numBytes, bytes.NewReader(data))
 	})
 }
diff --git a/p2p/protocol/circuitv2/relay/relay_priv_test.go b/p2p/protocol/circuitv2/relay/relay_priv_test.go
index dd07e8e7..637c53e9 100644
--- a/p2p/protocol/circuitv2/relay/relay_priv_test.go
+++ b/p2p/protocol/circuitv2/relay/relay_priv_test.go
@@ -42,7 +42,7 @@ func TestMakeReservationWithP2PAddrs(t *testing.T) {
 		"/ip4/1.2.3.4/tcp/1235/p2p/" + selfID.String(),
 	}
 
-	var addrsFromRsvp []string
+	addrsFromRsvp := make([]string, 0, len(rsvp.GetAddrs()))
 	for _, addr := range rsvp.GetAddrs() {
 		a, err := ma.NewMultiaddrBytes(addr)
 		require.NoError(t, err)
diff --git a/p2p/protocol/circuitv2/relay/relay_test.go b/p2p/protocol/circuitv2/relay/relay_test.go
index 7c5ec927..a2572053 100644
--- a/p2p/protocol/circuitv2/relay/relay_test.go
+++ b/p2p/protocol/circuitv2/relay/relay_test.go
@@ -30,7 +30,7 @@ import (
 	ma "github.com/multiformats/go-multiaddr"
 )
 
-func getNetHosts(t *testing.T, ctx context.Context, n int) (hosts []host.Host, upgraders []transport.Upgrader) {
+func getNetHosts(t *testing.T, _ context.Context, n int) (hosts []host.Host, upgraders []transport.Upgrader) {
 	for i := 0; i < n; i++ {
 		privk, pubk, err := crypto.GenerateKeyPair(crypto.Ed25519, 0)
 		if err != nil {
diff --git a/p2p/protocol/holepunch/holepunch_test.go b/p2p/protocol/holepunch/holepunch_test.go
index a7638807..09e46f10 100644
--- a/p2p/protocol/holepunch/holepunch_test.go
+++ b/p2p/protocol/holepunch/holepunch_test.go
@@ -345,13 +345,13 @@ func TestFailuresOnInitiator(t *testing.T) {
 		},
 		"responder does NOT reply within hole punch deadline": {
 			holePunchTimeout: 200 * time.Millisecond,
-			rhandler:         func(s network.Stream) { time.Sleep(5 * time.Second) },
+			rhandler:         func(_ network.Stream) { time.Sleep(5 * time.Second) },
 			errMsg:           "i/o deadline reached",
 		},
 		"no addrs after filtering": {
 			errMsg:   "aborting hole punch initiation as we have no public address",
-			rhandler: func(s network.Stream) { time.Sleep(5 * time.Second) },
-			filter: func(remoteID peer.ID, maddrs []ma.Multiaddr) []ma.Multiaddr {
+			rhandler: func(_ network.Stream) { time.Sleep(5 * time.Second) },
+			filter: func(_ peer.ID, _ []ma.Multiaddr) []ma.Multiaddr {
 				return []ma.Multiaddr{}
 			},
 		},
@@ -491,7 +491,7 @@ func TestFailuresOnResponder(t *testing.T) {
 				})
 				time.Sleep(10 * time.Second)
 			},
-			filter: func(remoteID peer.ID, maddrs []ma.Multiaddr) []ma.Multiaddr {
+			filter: func(_ peer.ID, _ []ma.Multiaddr) []ma.Multiaddr {
 				return []ma.Multiaddr{}
 			},
 		},
@@ -630,7 +630,7 @@ type MockSourceIPSelector struct {
 	ip atomic.Pointer[net.IP]
 }
 
-func (m *MockSourceIPSelector) PreferredSourceIPForDestination(dst *net.UDPAddr) (net.IP, error) {
+func (m *MockSourceIPSelector) PreferredSourceIPForDestination(_ *net.UDPAddr) (net.IP, error) {
 	return *m.ip.Load(), nil
 }
 
@@ -641,7 +641,7 @@ func quicSimConn(isPubliclyReachably bool, router *simconn.SimpleFirewallRouter)
 		quicreuse.OverrideSourceIPSelector(func() (quicreuse.SourceIPSelector, error) {
 			return m, nil
 		}),
-		quicreuse.OverrideListenUDP(func(network string, address *net.UDPAddr) (net.PacketConn, error) {
+		quicreuse.OverrideListenUDP(func(_ string, address *net.UDPAddr) (net.PacketConn, error) {
 			m.ip.Store(&address.IP)
 			c := simconn.NewSimConn(address, router)
 			if isPubliclyReachably {
diff --git a/p2p/protocol/identify/id_test.go b/p2p/protocol/identify/id_test.go
index 34d6c240..d0dc0541 100644
--- a/p2p/protocol/identify/id_test.go
+++ b/p2p/protocol/identify/id_test.go
@@ -837,7 +837,7 @@ func TestIdentifyResponseReadTimeout(t *testing.T) {
 	ids2.Start()
 
 	// remote stream handler will just hang and not send back an identify response
-	h2.SetStreamHandler(identify.ID, func(s network.Stream) {
+	h2.SetStreamHandler(identify.ID, func(_ network.Stream) {
 		time.Sleep(100 * time.Second)
 	})
 
@@ -910,7 +910,7 @@ func TestOutOfOrderConnectedNotifs(t *testing.T) {
 
 	// This callback may be called before identify's Connnected callback completes. If it does, the IdentifyWait should still finish successfully.
 	h1.Network().Notify(&network.NotifyBundle{
-		ConnectedF: func(n network.Network, c network.Conn) {
+		ConnectedF: func(_ network.Network, c network.Conn) {
 			idChan := h1.(interface{ IDService() identify.IDService }).IDService().IdentifyWait(c)
 			go func() {
 				<-idChan
@@ -958,7 +958,7 @@ func waitForDisconnectNotification(swarm *swarm.Swarm) <-chan struct{} {
 	var once sync.Once
 	var nb *network.NotifyBundle
 	nb = &network.NotifyBundle{
-		DisconnectedF: func(n network.Network, c network.Conn) {
+		DisconnectedF: func(_ network.Network, _ network.Conn) {
 			once.Do(func() {
 				go func() {
 					swarm.StopNotify(nb)
diff --git a/p2p/protocol/identify/obsaddr_test.go b/p2p/protocol/identify/obsaddr_test.go
index aad55bb3..f2261c01 100644
--- a/p2p/protocol/identify/obsaddr_test.go
+++ b/p2p/protocol/identify/obsaddr_test.go
@@ -466,7 +466,7 @@ func TestObservedAddrManager(t *testing.T) {
 			return checkAllEntriesRemoved(o)
 		}, 1*time.Second, 100*time.Millisecond)
 	})
-	t.Run("Nil Input", func(t *testing.T) {
+	t.Run("Nil Input", func(_ *testing.T) {
 		o := newObservedAddrMgr()
 		defer o.Close()
 		o.maybeRecordObservation(nil, nil)
@@ -655,7 +655,7 @@ func FuzzObservedAddrManager(f *testing.F) {
 		return o
 	}
 
-	f.Fuzz(func(t *testing.T, port uint16) {
+	f.Fuzz(func(_ *testing.T, port uint16) {
 		addrs := []ma.Multiaddr{genIPMultiaddr(true), genIPMultiaddr(false)}
 		n := len(addrs)
 		for i := 0; i < n; i++ {
diff --git a/p2p/security/noise/transport_test.go b/p2p/security/noise/transport_test.go
index ea7916fc..b80019d7 100644
--- a/p2p/security/noise/transport_test.go
+++ b/p2p/security/noise/transport_test.go
@@ -606,7 +606,7 @@ func TestEarlyDataRejected(t *testing.T) {
 
 func TestEarlyfffDataAcceptedWithNoHandler(t *testing.T) {
 	clientEDH := &earlyDataHandler{
-		send: func(ctx context.Context, conn net.Conn, id peer.ID) *pb.NoiseExtensions {
+		send: func(_ context.Context, _ net.Conn, _ peer.ID) *pb.NoiseExtensions {
 			return &pb.NoiseExtensions{WebtransportCerthashes: [][]byte{[]byte("foobar")}}
 		},
 	}
diff --git a/p2p/test/resource-manager/rcmgr_test.go b/p2p/test/resource-manager/rcmgr_test.go
index 4cdd5f2f..816c58da 100644
--- a/p2p/test/resource-manager/rcmgr_test.go
+++ b/p2p/test/resource-manager/rcmgr_test.go
@@ -291,7 +291,7 @@ func waitForChannel(ready chan struct{}, timeout time.Duration) func() error {
 	}
 }
 
-func TestReadmeExample(t *testing.T) {
+func TestReadmeExample(_ *testing.T) {
 	// Start with the default scaling limits.
 	scalingLimits := rcmgr.DefaultLimits
 
diff --git a/p2p/test/transport/rcmgr_test.go b/p2p/test/transport/rcmgr_test.go
index 8af42077..cd24a8e8 100644
--- a/p2p/test/transport/rcmgr_test.go
+++ b/p2p/test/transport/rcmgr_test.go
@@ -58,7 +58,7 @@ func TestResourceManagerIsUsed(t *testing.T) {
 					}
 
 					peerScope := mocknetwork.NewMockPeerScope(ctrl)
-					peerScope.EXPECT().ReserveMemory(gomock.Any(), gomock.Any()).AnyTimes().Do(func(amount int, pri uint8) {
+					peerScope.EXPECT().ReserveMemory(gomock.Any(), gomock.Any()).AnyTimes().Do(func(amount int, _ uint8) {
 						reservedMemory.Add(int32(amount))
 					})
 					peerScope.EXPECT().ReleaseMemory(gomock.Any()).AnyTimes().Do(func(amount int) {
diff --git a/p2p/test/transport/transport_test.go b/p2p/test/transport/transport_test.go
index 1cd1db27..f529488f 100644
--- a/p2p/test/transport/transport_test.go
+++ b/p2p/test/transport/transport_test.go
@@ -656,7 +656,7 @@ func TestMoreStreamsThanOurLimits(t *testing.T) {
 						var err error
 						// maxRetries is an arbitrary retry amount if there's any error.
 						maxRetries := streamCount * 4
-						shouldRetry := func(err error) bool {
+						shouldRetry := func(_ error) bool {
 							didErr = true
 							sawFirstErr.Store(true)
 							maxRetries--
diff --git a/p2p/transport/quicreuse/connmgr_test.go b/p2p/transport/quicreuse/connmgr_test.go
index 79f2c88e..7165c7e4 100644
--- a/p2p/transport/quicreuse/connmgr_test.go
+++ b/p2p/transport/quicreuse/connmgr_test.go
@@ -189,7 +189,7 @@ func getTLSConfForProto(t *testing.T, alpn string) (peer.ID, *tls.Config) {
 	require.NoError(t, err)
 	var tlsConf tls.Config
 	tlsConf.NextProtos = []string{alpn}
-	tlsConf.GetConfigForClient = func(info *tls.ClientHelloInfo) (*tls.Config, error) {
+	tlsConf.GetConfigForClient = func(_ *tls.ClientHelloInfo) (*tls.Config, error) {
 		c, _ := identity.ConfigForPeer("")
 		c.NextProtos = tlsConf.NextProtos
 		return c, nil
@@ -378,12 +378,12 @@ func TestAssociate(t *testing.T) {
 		require.Contains(t, []string{ln2.Addr().String(), ln3.Addr().String()}, tr3.LocalAddr().String())
 	}
 
-	t.Run("MultipleUnspecifiedListeners", func(t *testing.T) {
+	t.Run("MultipleUnspecifiedListeners", func(_ *testing.T) {
 		testAssociate(ma.StringCast("/ip4/0.0.0.0/udp/0/quic-v1"),
 			ma.StringCast("/ip4/0.0.0.0/udp/0/quic-v1"),
 			&net.UDPAddr{IP: net.IPv4(1, 1, 1, 1), Port: 1})
 	})
-	t.Run("MultipleSpecificListeners", func(t *testing.T) {
+	t.Run("MultipleSpecificListeners", func(_ *testing.T) {
 		testAssociate(ma.StringCast("/ip4/127.0.0.1/udp/0/quic-v1"),
 			ma.StringCast("/ip4/127.0.0.1/udp/0/quic-v1"),
 			&net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1},
diff --git a/p2p/transport/tcp/tcp_test.go b/p2p/transport/tcp/tcp_test.go
index 1a712acf..8fff3ce4 100644
--- a/p2p/transport/tcp/tcp_test.go
+++ b/p2p/transport/tcp/tcp_test.go
@@ -211,7 +211,7 @@ type errDialer struct {
 	err error
 }
 
-func (d errDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
+func (d errDialer) DialContext(_ context.Context, _, _ string) (net.Conn, error) {
 	return nil, d.err
 }
 
@@ -230,7 +230,7 @@ func TestCustomOverrideTCPDialer(t *testing.T) {
 		ub, err := tptu.New(ib, muxers, nil, nil, nil)
 		require.NoError(t, err)
 		called := false
-		customDialer := func(raddr ma.Multiaddr) (ContextDialer, error) {
+		customDialer := func(_ ma.Multiaddr) (ContextDialer, error) {
 			called = true
 			return &net.Dialer{}, nil
 		}
@@ -260,7 +260,7 @@ func TestCustomOverrideTCPDialer(t *testing.T) {
 				ub, err := tptu.New(ib, muxers, nil, nil, nil)
 				require.NoError(t, err)
 				customErr := errors.New("custom dialer error")
-				customDialer := func(raddr ma.Multiaddr) (ContextDialer, error) {
+				customDialer := func(_ ma.Multiaddr) (ContextDialer, error) {
 					if test == "error in factory" {
 						return nil, customErr
 					} else {
diff --git a/p2p/transport/testsuite/transport_suite.go b/p2p/transport/testsuite/transport_suite.go
index bd8892e8..a24b2c6a 100644
--- a/p2p/transport/testsuite/transport_suite.go
+++ b/p2p/transport/testsuite/transport_suite.go
@@ -16,7 +16,7 @@ import (
 
 var testData = []byte("this is some test data")
 
-func SubtestProtocols(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID) {
+func SubtestProtocols(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, _ peer.ID) {
 	rawIPAddr, _ := ma.NewMultiaddr("/ip4/1.2.3.4")
 	if ta.CanDial(rawIPAddr) || tb.CanDial(rawIPAddr) {
 		t.Error("nothing should be able to dial raw IP")
diff --git a/p2p/transport/websocket/websocket_test.go b/p2p/transport/websocket/websocket_test.go
index 2c47adf3..fb607443 100644
--- a/p2p/transport/websocket/websocket_test.go
+++ b/p2p/transport/websocket/websocket_test.go
@@ -669,7 +669,7 @@ func TestHandshakeTimeout(t *testing.T) {
 	fastWSDialer := gws.Dialer{
 		HandshakeTimeout: 10 * handshakeTimeout,
 		TLSClientConfig:  &tls.Config{InsecureSkipVerify: true},
-		NetDial: func(network, addr string) (net.Conn, error) {
+		NetDial: func(_, addr string) (net.Conn, error) {
 			tcpConn, err := net.Dial("tcp", addr)
 			if !assert.NoError(t, err) {
 				return nil, err
@@ -680,7 +680,7 @@ func TestHandshakeTimeout(t *testing.T) {
 
 	slowWSDialer := gws.Dialer{
 		HandshakeTimeout: 10 * handshakeTimeout,
-		NetDial: func(network, addr string) (net.Conn, error) {
+		NetDial: func(_, addr string) (net.Conn, error) {
 			tcpConn, err := net.Dial("tcp", addr)
 			if !assert.NoError(t, err) {
 				return nil, err
diff --git a/p2p/transport/webtransport/transport_test.go b/p2p/transport/webtransport/transport_test.go
index e2817ee4..266e01d1 100644
--- a/p2p/transport/webtransport/transport_test.go
+++ b/p2p/transport/webtransport/transport_test.go
@@ -526,7 +526,7 @@ type reportingRcmgr struct {
 	report chan<- int
 }
 
-func (m *reportingRcmgr) OpenConnection(dir network.Direction, usefd bool, endpoint ma.Multiaddr) (network.ConnManagementScope, error) {
+func (m *reportingRcmgr) OpenConnection(_ network.Direction, _ bool, _ ma.Multiaddr) (network.ConnManagementScope, error) {
 	return &reportingScope{report: m.report}, nil
 }
 
@@ -681,7 +681,7 @@ func serverSendsBackValidCert(t *testing.T, timeSinceUnixEpoch time.Duration, ke
 	conn, err := quic.DialAddr(context.Background(), l.Addr().String(), &tls.Config{
 		NextProtos:         []string{http3.NextProtoH3},
 		InsecureSkipVerify: true,
-		VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
+		VerifyPeerCertificate: func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
 			for _, c := range rawCerts {
 				cert, err := x509.ParseCertificate(c)
 				if err != nil {