From fda6c4f836f5a6cd61a4c1d9b20249bed715ab8d Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Sat, 16 Mar 2024 21:09:38 -0400 Subject: [PATCH] Fix linter errors golangci-lint upgrade to v1.56.2 added more checks Relates to pion/.goassets#201 --- datachannel_go_test.go | 10 ++++----- datachannel_test.go | 14 ++++++------ dtlstransport_test.go | 4 ++-- .../bandwidth-estimation-from-disk/main.go | 2 +- examples/broadcast/main.go | 2 +- examples/pion-to-pion/answer/main.go | 4 ++-- examples/pion-to-pion/offer/main.go | 4 ++-- examples/reflect/main.go | 2 +- examples/rtp-forwarder/main.go | 2 +- examples/save-to-disk-av1/main.go | 2 +- examples/save-to-disk/main.go | 2 +- examples/simulcast/main.go | 2 +- examples/stats/main.go | 2 +- examples/swap-tracks/main.go | 2 +- icetransport_test.go | 2 +- interceptor_test.go | 10 ++++----- peerconnection_go_test.go | 20 ++++++++--------- peerconnection_media_test.go | 10 ++++----- peerconnection_renegotiation_test.go | 22 +++++++++---------- peerconnection_test.go | 4 ++-- pkg/media/samplebuilder/samplebuilder_test.go | 2 +- rtpreceiver_go_test.go | 2 +- rtpsender.go | 2 +- sdp.go | 2 +- stats_go_test.go | 2 +- track_local_static_test.go | 2 +- 26 files changed, 67 insertions(+), 67 deletions(-) diff --git a/datachannel_go_test.go b/datachannel_go_test.go index 8c02a820b83..72be159b2f9 100644 --- a/datachannel_go_test.go +++ b/datachannel_go_test.go @@ -52,7 +52,7 @@ func TestDataChannel_EventHandlers(t *testing.T) { close(onOpenCalled) }) - dc.OnMessage(func(p DataChannelMessage) { + dc.OnMessage(func(DataChannelMessage) { close(onMessageCalled) }) @@ -222,7 +222,7 @@ func TestDataChannelBufferedAmount(t *testing.T) { } }) - answerDC.OnMessage(func(msg DataChannelMessage) { + answerDC.OnMessage(func(DataChannelMessage) { atomic.AddUint32(&nAnswerReceived, 1) }) assert.True(t, answerDC.Ordered(), "Ordered should be set to true") @@ -259,7 +259,7 @@ func TestDataChannelBufferedAmount(t *testing.T) { } }) - offerDC.OnMessage(func(msg DataChannelMessage) { + offerDC.OnMessage(func(DataChannelMessage) { atomic.AddUint32(&nOfferReceived, 1) }) @@ -309,7 +309,7 @@ func TestDataChannelBufferedAmount(t *testing.T) { return } var nPacketsReceived int - d.OnMessage(func(msg DataChannelMessage) { + d.OnMessage(func(DataChannelMessage) { nPacketsReceived++ if nPacketsReceived == 10 { @@ -347,7 +347,7 @@ func TestDataChannelBufferedAmount(t *testing.T) { } }) - dc.OnMessage(func(msg DataChannelMessage) { + dc.OnMessage(func(DataChannelMessage) { }) err = signalPair(offerPC, answerPC) diff --git a/datachannel_test.go b/datachannel_test.go index 06f22e24d87..5969da815d4 100644 --- a/datachannel_test.go +++ b/datachannel_test.go @@ -135,7 +135,7 @@ func TestDataChannel_Open(t *testing.T) { d.OnOpen(func() { openCalls <- true }) - d.OnMessage(func(msg DataChannelMessage) { + d.OnMessage(func(DataChannelMessage) { go func() { // Wait a little bit to ensure all messages are processed. time.Sleep(100 * time.Millisecond) @@ -191,7 +191,7 @@ func TestDataChannel_Open(t *testing.T) { }) assert.NoError(t, err) - answerDC.OnMessage(func(msg DataChannelMessage) { + answerDC.OnMessage(func(DataChannelMessage) { go func() { // Wait a little bit to ensure all messages are processed. time.Sleep(100 * time.Millisecond) @@ -237,7 +237,7 @@ func TestDataChannel_Send(t *testing.T) { if d.Label() != expectedLabel { return } - d.OnMessage(func(msg DataChannelMessage) { + d.OnMessage(func(DataChannelMessage) { e := d.Send([]byte("Pong")) if e != nil { t.Fatalf("Failed to send string on data channel") @@ -259,7 +259,7 @@ func TestDataChannel_Send(t *testing.T) { t.Fatalf("Failed to send string on data channel") } }) - dc.OnMessage(func(msg DataChannelMessage) { + dc.OnMessage(func(DataChannelMessage) { done <- true }) @@ -288,7 +288,7 @@ func TestDataChannel_Send(t *testing.T) { if d.Label() != expectedLabel { return } - d.OnMessage(func(msg DataChannelMessage) { + d.OnMessage(func(DataChannelMessage) { e := d.Send([]byte("Pong")) if e != nil { t.Fatalf("Failed to send string on data channel") @@ -309,7 +309,7 @@ func TestDataChannel_Send(t *testing.T) { assert.True(t, dc.Ordered(), "Ordered should be set to true") - dc.OnMessage(func(msg DataChannelMessage) { + dc.OnMessage(func(DataChannelMessage) { done <- true }) @@ -477,7 +477,7 @@ func TestDataChannelParameters(t *testing.T) { t.Fatal("OnDataChannel must not be fired when negotiated == true") }) - offerPC.OnDataChannel(func(d *DataChannel) { + offerPC.OnDataChannel(func(*DataChannel) { t.Fatal("OnDataChannel must not be fired when negotiated == true") }) diff --git a/dtlstransport_test.go b/dtlstransport_test.go index 485d1534f7a..bc3dc5520de 100644 --- a/dtlstransport_test.go +++ b/dtlstransport_test.go @@ -130,11 +130,11 @@ func TestPeerConnection_DTLSRoleSettingEngine(t *testing.T) { report := test.CheckRoutines(t) defer report() - t.Run("Server", func(t *testing.T) { + t.Run("Server", func(*testing.T) { runTest(DTLSRoleServer) }) - t.Run("Client", func(t *testing.T) { + t.Run("Client", func(*testing.T) { runTest(DTLSRoleClient) }) } diff --git a/examples/bandwidth-estimation-from-disk/main.go b/examples/bandwidth-estimation-from-disk/main.go index 1fd012a01bc..c1cf585f87c 100644 --- a/examples/bandwidth-estimation-from-disk/main.go +++ b/examples/bandwidth-estimation-from-disk/main.go @@ -74,7 +74,7 @@ func main() { } estimatorChan := make(chan cc.BandwidthEstimator, 1) - congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) { + congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) { //nolint: revive estimatorChan <- estimator }) diff --git a/examples/broadcast/main.go b/examples/broadcast/main.go index f6c315fcee9..22a3d914ddc 100644 --- a/examples/broadcast/main.go +++ b/examples/broadcast/main.go @@ -83,7 +83,7 @@ func main() { // nolint:gocognit localTrackChan := make(chan *webrtc.TrackLocalStaticRTP) // Set a handler for when a new remote track starts, this just distributes all our packets // to connected peers - peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive // Create a local track, all our SFU clients will be fed via this track localTrack, newTrackErr := webrtc.NewTrackLocalStaticRTP(remoteTrack.Codec().RTPCodecCapability, "video", "pion") if newTrackErr != nil { diff --git a/examples/pion-to-pion/answer/main.go b/examples/pion-to-pion/answer/main.go index 3b0b6cb491a..627e8121a02 100644 --- a/examples/pion-to-pion/answer/main.go +++ b/examples/pion-to-pion/answer/main.go @@ -80,7 +80,7 @@ func main() { // nolint:gocognit // A HTTP handler that allows the other Pion instance to send us ICE candidates // This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN // candidates which may be slower - http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive candidate, candidateErr := ioutil.ReadAll(r.Body) if candidateErr != nil { panic(candidateErr) @@ -91,7 +91,7 @@ func main() { // nolint:gocognit }) // A HTTP handler that processes a SessionDescription given to us from the other Pion process - http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { // nolint: revive sdp := webrtc.SessionDescription{} if err := json.NewDecoder(r.Body).Decode(&sdp); err != nil { panic(err) diff --git a/examples/pion-to-pion/offer/main.go b/examples/pion-to-pion/offer/main.go index ebf32c5c095..2243fb7c088 100644 --- a/examples/pion-to-pion/offer/main.go +++ b/examples/pion-to-pion/offer/main.go @@ -80,7 +80,7 @@ func main() { //nolint:gocognit // A HTTP handler that allows the other Pion instance to send us ICE candidates // This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN // candidates which may be slower - http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive candidate, candidateErr := ioutil.ReadAll(r.Body) if candidateErr != nil { panic(candidateErr) @@ -91,7 +91,7 @@ func main() { //nolint:gocognit }) // A HTTP handler that processes a SessionDescription given to us from the other Pion process - http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { //nolint: revive sdp := webrtc.SessionDescription{} if sdpErr := json.NewDecoder(r.Body).Decode(&sdp); sdpErr != nil { panic(sdpErr) diff --git a/examples/reflect/main.go b/examples/reflect/main.go index 6d8428aae64..ff859432f90 100644 --- a/examples/reflect/main.go +++ b/examples/reflect/main.go @@ -112,7 +112,7 @@ func main() { // Set a handler for when a new remote track starts, this handler copies inbound RTP packets, // replaces the SSRC and sends them back - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType) for { // Read RTP packets being sent to Pion diff --git a/examples/rtp-forwarder/main.go b/examples/rtp-forwarder/main.go index 03a03c8be21..57d02816f5c 100644 --- a/examples/rtp-forwarder/main.go +++ b/examples/rtp-forwarder/main.go @@ -131,7 +131,7 @@ func main() { // Set a handler for when a new remote track starts, this handler will forward data to // our UDP listeners. // In your application this is where you would handle/process audio/video - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive // Retrieve udp connection c, ok := udpConns[track.Kind().String()] if !ok { diff --git a/examples/save-to-disk-av1/main.go b/examples/save-to-disk-av1/main.go index c6de280568e..29f03e59d7c 100644 --- a/examples/save-to-disk-av1/main.go +++ b/examples/save-to-disk-av1/main.go @@ -101,7 +101,7 @@ func main() { // Set a handler for when a new remote track starts, this handler saves buffers to disk as // an ivf file, since we could have multiple video tracks we provide a counter. // In your application this is where you would handle/process video - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive if strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeAV1) { fmt.Println("Got AV1 track, saving to disk as output.ivf") saveToDisk(ivfFile, track) diff --git a/examples/save-to-disk/main.go b/examples/save-to-disk/main.go index 3e5abfa82a7..1113f422081 100644 --- a/examples/save-to-disk/main.go +++ b/examples/save-to-disk/main.go @@ -121,7 +121,7 @@ func main() { // Set a handler for when a new remote track starts, this handler saves buffers to disk as // an ivf file, since we could have multiple video tracks we provide a counter. // In your application this is where you would handle/process video - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive codec := track.Codec() if strings.EqualFold(codec.MimeType, webrtc.MimeTypeOpus) { fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)") diff --git a/examples/simulcast/main.go b/examples/simulcast/main.go index 5ae22f1c36c..ded6bdfe07d 100644 --- a/examples/simulcast/main.go +++ b/examples/simulcast/main.go @@ -99,7 +99,7 @@ func main() { } // Set a handler for when a new remote track starts - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive fmt.Println("Track has started") // Start reading from all the streams and sending them to the related output track diff --git a/examples/stats/main.go b/examples/stats/main.go index 18b565985bb..9d3a9574f8e 100644 --- a/examples/stats/main.go +++ b/examples/stats/main.go @@ -77,7 +77,7 @@ func main() { // Set a handler for when a new remote track starts. We read the incoming packets, but then // immediately discard them - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive fmt.Printf("New incoming track with codec: %s\n", track.Codec().MimeType) go func() { diff --git a/examples/swap-tracks/main.go b/examples/swap-tracks/main.go index d4f301150eb..85935baa8fb 100644 --- a/examples/swap-tracks/main.go +++ b/examples/swap-tracks/main.go @@ -84,7 +84,7 @@ func main() { // nolint:gocognit packets := make(chan *rtp.Packet, 60) // Set a handler for when a new remote track starts - peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { + peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType) trackNum := trackCount trackCount++ diff --git a/icetransport_test.go b/icetransport_test.go index 4a148fd8fd2..0d7d55e0427 100644 --- a/icetransport_test.go +++ b/icetransport_test.go @@ -75,7 +75,7 @@ func TestICETransport_OnSelectedCandidatePairChange(t *testing.T) { }) senderCalledCandidateChange := int32(0) - pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(pair *ICECandidatePair) { + pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(*ICECandidatePair) { atomic.StoreInt32(&senderCalledCandidateChange, 1) }) diff --git a/interceptor_test.go b/interceptor_test.go index e7d8e49d3e6..31cfe058341 100644 --- a/interceptor_test.go +++ b/interceptor_test.go @@ -80,7 +80,7 @@ func TestPeerConnection_Interceptor(t *testing.T) { assert.NoError(t, err) seenRTP, seenRTPCancel := context.WithCancel(context.Background()) - answerer.OnTrack(func(track *TrackRemote, receiver *RTPReceiver) { + answerer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { p, attributes, readErr := track.ReadRTP() assert.NoError(t, readErr) @@ -136,18 +136,18 @@ func Test_Interceptor_BindUnbind(t *testing.T) { atomic.AddUint32(&cntBindRTCPWriter, 1) return writer }, - BindLocalStreamFn: func(i *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter { + BindLocalStreamFn: func(_ *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter { atomic.AddUint32(&cntBindLocalStream, 1) return writer }, - UnbindLocalStreamFn: func(i *interceptor.StreamInfo) { + UnbindLocalStreamFn: func(*interceptor.StreamInfo) { atomic.AddUint32(&cntUnbindLocalStream, 1) }, - BindRemoteStreamFn: func(i *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader { + BindRemoteStreamFn: func(_ *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader { atomic.AddUint32(&cntBindRemoteStream, 1) return reader }, - UnbindRemoteStreamFn: func(i *interceptor.StreamInfo) { + UnbindRemoteStreamFn: func(_ *interceptor.StreamInfo) { atomic.AddUint32(&cntUnbindRemoteStream, 1) }, CloseFn: func() error { diff --git a/peerconnection_go_test.go b/peerconnection_go_test.go index 146d7726cad..e36c62f75b4 100644 --- a/peerconnection_go_test.go +++ b/peerconnection_go_test.go @@ -306,11 +306,11 @@ func TestPeerConnection_EventHandlers_Go(t *testing.T) { assert.NotPanics(t, func() { pc.onTrack(nil, nil) }) assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) }) - pc.OnTrack(func(t *TrackRemote, r *RTPReceiver) { + pc.OnTrack(func(*TrackRemote, *RTPReceiver) { close(onTrackCalled) }) - pc.OnICEConnectionStateChange(func(cs ICEConnectionState) { + pc.OnICEConnectionStateChange(func(ICEConnectionState) { close(onICEConnectionStateChangeCalled) }) @@ -601,15 +601,15 @@ func TestPeerConnection_IceLite(t *testing.T) { closePairNow(t, offerPC, answerPC) } - t.Run("Offerer", func(t *testing.T) { + t.Run("Offerer", func(*testing.T) { connectTwoAgents(true, false) }) - t.Run("Answerer", func(t *testing.T) { + t.Run("Answerer", func(*testing.T) { connectTwoAgents(false, true) }) - t.Run("Both", func(t *testing.T) { + t.Run("Both", func(*testing.T) { connectTwoAgents(true, true) }) } @@ -808,7 +808,7 @@ func TestMulticastDNSCandidates(t *testing.T) { assert.NoError(t, signalPair(pcOffer, pcAnswer)) onDataChannel, onDataChannelCancel := context.WithCancel(context.Background()) - pcAnswer.OnDataChannel(func(d *DataChannel) { + pcAnswer.OnDataChannel(func(*DataChannel) { onDataChannelCancel() }) <-onDataChannel.Done() @@ -941,7 +941,7 @@ func TestICERestart_Error_Handling(t *testing.T) { keepPackets.set(true) // Add a filter that monitors the traffic on the router - wan.AddChunkFilter(func(c vnet.Chunk) bool { + wan.AddChunkFilter(func(vnet.Chunk) bool { return keepPackets.get() }) @@ -1361,21 +1361,21 @@ func TestPeerConnectionNilCallback(t *testing.T) { assert.NoError(t, err) pc.onSignalingStateChange(SignalingStateStable) - pc.OnSignalingStateChange(func(ss SignalingState) { + pc.OnSignalingStateChange(func(SignalingState) { t.Error("OnSignalingStateChange called") }) pc.OnSignalingStateChange(nil) pc.onSignalingStateChange(SignalingStateStable) pc.onConnectionStateChange(PeerConnectionStateNew) - pc.OnConnectionStateChange(func(pcs PeerConnectionState) { + pc.OnConnectionStateChange(func(PeerConnectionState) { t.Error("OnConnectionStateChange called") }) pc.OnConnectionStateChange(nil) pc.onConnectionStateChange(PeerConnectionStateNew) pc.onICEConnectionStateChange(ICEConnectionStateNew) - pc.OnICEConnectionStateChange(func(ics ICEConnectionState) { + pc.OnICEConnectionStateChange(func(ICEConnectionState) { t.Error("OnConnectionStateChange called") }) pc.OnICEConnectionStateChange(nil) diff --git a/peerconnection_media_test.go b/peerconnection_media_test.go index 044c7c21eda..4d638ebdf9f 100644 --- a/peerconnection_media_test.go +++ b/peerconnection_media_test.go @@ -252,7 +252,7 @@ func TestPeerConnection_Media_Shutdown(t *testing.T) { var onTrackFiredLock sync.Mutex onTrackFired := false - pcAnswer.OnTrack(func(track *TrackRemote, receiver *RTPReceiver) { + pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackFiredLock.Lock() defer onTrackFiredLock.Unlock() onTrackFired = true @@ -327,7 +327,7 @@ func TestPeerConnection_Media_Disconnected(t *testing.T) { keepPackets.set(true) // Add a filter that monitors the traffic on the router - wan.AddChunkFilter(func(c vnet.Chunk) bool { + wan.AddChunkFilter(func(vnet.Chunk) bool { return keepPackets.get() }) @@ -438,7 +438,7 @@ func TestUndeclaredSSRC(t *testing.T) { assert.NoError(t, err) onTrackFired := make(chan struct{}) - pcAnswer.OnTrack(func(trackRemote *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(trackRemote *TrackRemote, _ *RTPReceiver) { assert.Equal(t, trackRemote.StreamID(), vp8Writer.StreamID()) assert.Equal(t, trackRemote.ID(), vp8Writer.ID()) close(onTrackFired) @@ -793,7 +793,7 @@ func TestPlanBMediaExchange(t *testing.T) { var onTrackWaitGroup sync.WaitGroup onTrackWaitGroup.Add(trackCount) - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackWaitGroup.Done() }) @@ -1422,7 +1422,7 @@ func TestPeerConnection_Simulcast_NoDataChannel(t *testing.T) { pcSender.OnConnectionStateChange(connectionStateChangeHandler) pcReceiver.OnConnectionStateChange(connectionStateChangeHandler) - pcReceiver.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { + pcReceiver.OnTrack(func(*TrackRemote, *RTPReceiver) { defer wg.Done() }) diff --git a/peerconnection_renegotiation_test.go b/peerconnection_renegotiation_test.go index 0dec5bec2f0..ac923d9dab9 100644 --- a/peerconnection_renegotiation_test.go +++ b/peerconnection_renegotiation_test.go @@ -128,12 +128,12 @@ func TestPeerConnection_Renegotiation_AddRecvonlyTransceiver(t *testing.T) { onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) if tc.answererSends { - pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcOffer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackFiredFunc() }) assert.NoError(t, signalPair(pcAnswer, pcOffer)) } else { - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackFiredFunc() }) assert.NoError(t, signalPair(pcOffer, pcAnswer)) @@ -166,7 +166,7 @@ func TestPeerConnection_Renegotiation_AddTrack(t *testing.T) { haveRenegotiated := &atomicBool{} onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) { if !haveRenegotiated.get() { t.Fatal("OnTrack was called before renegotiation") } @@ -246,7 +246,7 @@ func TestPeerConnection_Renegotiation_AddTrack_Multiple(t *testing.T) { t.Fatal(err) } - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { onTrackCount[track.ID()]++ onTrackChan <- struct{}{} }) @@ -288,7 +288,7 @@ func TestPeerConnection_Renegotiation_AddTrack_Rename(t *testing.T) { haveRenegotiated := &atomicBool{} onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) var atomicRemoteTrack atomic.Value - pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcOffer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { if !haveRenegotiated.get() { t.Fatal("OnTrack was called before renegotiation") } @@ -445,7 +445,7 @@ func TestPeerConnection_Renegotiation_CodecChange(t *testing.T) { tracksCh := make(chan *TrackRemote) tracksClosed := make(chan struct{}) - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { tracksCh <- track for { if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) { @@ -533,7 +533,7 @@ func TestPeerConnection_Renegotiation_RemoveTrack(t *testing.T) { onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) trackClosed, trackClosedFunc := context.WithCancel(context.Background()) - pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { onTrackFiredFunc() for { @@ -567,7 +567,7 @@ func TestPeerConnection_RoleSwitch(t *testing.T) { } onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) - pcFirstOfferer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcFirstOfferer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackFiredFunc() }) @@ -673,7 +673,7 @@ func TestPeerConnection_Renegotiation_SetLocalDescription(t *testing.T) { } onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) - pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcOffer.OnTrack(func(*TrackRemote, *RTPReceiver) { onTrackFiredFunc() }) @@ -1244,7 +1244,7 @@ func TestPeerConnection_Regegotiation_AnswerAddsTrack(t *testing.T) { } tracksCh := make(chan *TrackRemote) - pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + pcOffer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { tracksCh <- track for { if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) { @@ -1309,7 +1309,7 @@ func TestNegotiationNeededWithRecvonlyTrack(t *testing.T) { } onDataChannel, onDataChannelCancel := context.WithCancel(context.Background()) - pcAnswer.OnDataChannel(func(d *DataChannel) { + pcAnswer.OnDataChannel(func(*DataChannel) { onDataChannelCancel() }) <-onDataChannel.Done() diff --git a/peerconnection_test.go b/peerconnection_test.go index a1579a59454..01a0b24c547 100644 --- a/peerconnection_test.go +++ b/peerconnection_test.go @@ -470,7 +470,7 @@ func TestMultipleOfferAnswer(t *testing.T) { if err != nil { t.Errorf("New PeerConnection: got error: %v", err) } - secondPeerConn.OnICECandidate(func(i *ICECandidate) { + secondPeerConn.OnICECandidate(func(*ICECandidate) { }) if _, err = secondPeerConn.CreateOffer(nil); err != nil { @@ -566,7 +566,7 @@ func TestMultipleCreateChannel(t *testing.T) { pcOffer, _ := NewPeerConnection(Configuration{}) pcAnswer, _ := NewPeerConnection(Configuration{}) - pcAnswer.OnDataChannel(func(d *DataChannel) { + pcAnswer.OnDataChannel(func(*DataChannel) { wg.Done() }) diff --git a/pkg/media/samplebuilder/samplebuilder_test.go b/pkg/media/samplebuilder/samplebuilder_test.go index c5fc75846aa..aa9c63cf1a5 100644 --- a/pkg/media/samplebuilder/samplebuilder_test.go +++ b/pkg/media/samplebuilder/samplebuilder_test.go @@ -473,7 +473,7 @@ func TestSampleBuilderWithPacketHeadHandler(t *testing.T) { } headCount := 0 - s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(headPacket interface{}) interface{} { + s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(interface{}) interface{} { headCount++ return true })) diff --git a/rtpreceiver_go_test.go b/rtpreceiver_go_test.go index 7ea51cb767c..911f0c83822 100644 --- a/rtpreceiver_go_test.go +++ b/rtpreceiver_go_test.go @@ -42,7 +42,7 @@ func TestSetRTPParameters(t *testing.T) { } seenPacket, seenPacketCancel := context.WithCancel(context.Background()) - receiver.OnTrack(func(trackRemote *TrackRemote, r *RTPReceiver) { + receiver.OnTrack(func(_ *TrackRemote, r *RTPReceiver) { r.SetRTPParameters(p) incomingTrackCodecs := r.Track().Codec() diff --git a/rtpsender.go b/rtpsender.go index 71be3fdb796..79d58d6371c 100644 --- a/rtpsender.go +++ b/rtpsender.go @@ -333,7 +333,7 @@ func (r *RTPSender) Send(parameters RTPSendParameters) error { rtpInterceptor := r.api.interceptor.BindLocalStream( &trackEncoding.streamInfo, - interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) { + interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, _ interceptor.Attributes) (int, error) { return srtpStream.WriteRTP(header, payload) }), ) diff --git a/sdp.go b/sdp.go index 49783d91aca..980f9850779 100644 --- a/sdp.go +++ b/sdp.go @@ -541,7 +541,7 @@ type mediaSection struct { func bundleMatchFromRemote(matchBundleGroup *string) func(mid string) bool { if matchBundleGroup == nil { - return func(midValue string) bool { + return func(string) bool { return true } } diff --git a/stats_go_test.go b/stats_go_test.go index 829dc6a9581..e707084d635 100644 --- a/stats_go_test.go +++ b/stats_go_test.go @@ -1241,7 +1241,7 @@ func TestPeerConnection_GetStats(t *testing.T) { d.OnOpen(func() { answerDCChan <- d }) - d.OnMessage(func(m DataChannelMessage) { + d.OnMessage(func(DataChannelMessage) { dcWait.Done() }) }) diff --git a/track_local_static_test.go b/track_local_static_test.go index 423d3942ec2..25d19a063cb 100644 --- a/track_local_static_test.go +++ b/track_local_static_test.go @@ -149,7 +149,7 @@ func Test_TrackLocalStatic_PayloadType(t *testing.T) { assert.NoError(t, err) onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background()) - offerer.OnTrack(func(track *TrackRemote, r *RTPReceiver) { + offerer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) { assert.Equal(t, track.PayloadType(), PayloadType(100)) assert.Equal(t, track.Codec().RTPCodecCapability.MimeType, "video/VP8")