diff --git a/.golangci.yml b/.golangci.yml index d2c93841..33a993a4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,6 +15,7 @@ linters: - nilerr - prealloc - revive + - usestdlibvars - unconvert - tparallel - wastedassign diff --git a/Makefile b/Makefile index e578be9b..15e7cd26 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BASE_IMAGE = golang:1.21-alpine3.19 -LINT_IMAGE = golangci/golangci-lint:v1.55.2 +LINT_IMAGE = golangci/golangci-lint:v1.56.2 NODE_IMAGE = node:20-alpine3.19 ALPINE_IMAGE = alpine:3.19 RPI32_IMAGE = balenalib/raspberry-pi:bullseye-run-20230712 diff --git a/internal/conf/env/env_test.go b/internal/conf/env/env_test.go index 3de2759a..47ff7e39 100644 --- a/internal/conf/env/env_test.go +++ b/internal/conf/env/env_test.go @@ -194,7 +194,7 @@ func FuzzLoad(f *testing.F) { f.Add("MYPREFIX_MYDURATION", "a") f.Add("MYPREFIX_MYDURATION_A", "a") - f.Fuzz(func(t *testing.T, key string, val string) { + f.Fuzz(func(_ *testing.T, key string, val string) { env := map[string]string{ key: val, } diff --git a/internal/core/path_test.go b/internal/core/path_test.go index edaa214d..9c861351 100644 --- a/internal/core/path_test.go +++ b/internal/core/path_test.go @@ -650,12 +650,12 @@ func TestPathSourceRegexp(t *testing.T) { StatusCode: base.StatusOK, }, stream, nil }, - onSetup: func(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { + onSetup: func(_ *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { return &base.Response{ StatusCode: base.StatusOK, }, stream, nil }, - onPlay: func(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { + onPlay: func(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { return &base.Response{ StatusCode: base.StatusOK, }, nil diff --git a/internal/formatprocessor/h264_test.go b/internal/formatprocessor/h264_test.go index bf1fdeb1..a5d18495 100644 --- a/internal/formatprocessor/h264_test.go +++ b/internal/formatprocessor/h264_test.go @@ -202,7 +202,7 @@ func TestH264EmptyPacket(t *testing.T) { } func FuzzRTPH264ExtractParams(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { rtpH264ExtractParams(b) }) } diff --git a/internal/formatprocessor/h265_test.go b/internal/formatprocessor/h265_test.go index 7ad5d86c..dd478d24 100644 --- a/internal/formatprocessor/h265_test.go +++ b/internal/formatprocessor/h265_test.go @@ -198,7 +198,7 @@ func TestH265EmptyPacket(t *testing.T) { } func FuzzRTPH265ExtractParams(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { rtpH265ExtractParams(b) }) } diff --git a/internal/protocols/rtmp/amf0/unmarshal_test.go b/internal/protocols/rtmp/amf0/unmarshal_test.go index d8ff0a55..b4564ec9 100644 --- a/internal/protocols/rtmp/amf0/unmarshal_test.go +++ b/internal/protocols/rtmp/amf0/unmarshal_test.go @@ -307,7 +307,7 @@ func FuzzUnmarshal(f *testing.F) { f.Add(ca.enc) } - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { Unmarshal(b) //nolint:errcheck }) } diff --git a/internal/protocols/rtmp/chunk/chunk_test.go b/internal/protocols/rtmp/chunk/chunk_test.go index 9748aaae..750ec753 100644 --- a/internal/protocols/rtmp/chunk/chunk_test.go +++ b/internal/protocols/rtmp/chunk/chunk_test.go @@ -158,28 +158,28 @@ func TestChunkMarshal(t *testing.T) { } func FuzzChunk0Read(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { var chunk Chunk0 chunk.Read(bytes.NewReader(b), 65536, false) //nolint:errcheck }) } func FuzzChunk1Read(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { var chunk Chunk1 chunk.Read(bytes.NewReader(b), 65536, false) //nolint:errcheck }) } func FuzzChunk2Read(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { var chunk Chunk2 chunk.Read(bytes.NewReader(b), 65536, false) //nolint:errcheck }) } func FuzzChunk3Read(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { var chunk Chunk3 chunk.Read(bytes.NewReader(b), 65536, true) //nolint:errcheck }) diff --git a/internal/protocols/rtmp/message/reader_test.go b/internal/protocols/rtmp/message/reader_test.go index ff8d3386..5ce3af1d 100644 --- a/internal/protocols/rtmp/message/reader_test.go +++ b/internal/protocols/rtmp/message/reader_test.go @@ -297,7 +297,7 @@ func FuzzReader(f *testing.F) { 0x01, 0x00, 0x00, 0x00, 0x88, 0x68, 0x76, 0x63, 0x31, 0x01, 0x02, 0x03, }) - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { bc := bytecounter.NewReader(bytes.NewReader(b)) r := NewReader(bc, bc, nil) r.Read() //nolint:errcheck diff --git a/internal/protocols/rtmp/rawmessage/reader_test.go b/internal/protocols/rtmp/rawmessage/reader_test.go index 6b65b28e..ee59c393 100644 --- a/internal/protocols/rtmp/rawmessage/reader_test.go +++ b/internal/protocols/rtmp/rawmessage/reader_test.go @@ -205,7 +205,7 @@ func TestReader(t *testing.T) { t.Run(ca.name, func(t *testing.T) { var buf bytes.Buffer br := bytecounter.NewReader(&buf) - r := NewReader(br, br, func(count uint32) error { + r := NewReader(br, br, func(_ uint32) error { return nil }) @@ -234,7 +234,7 @@ func TestReaderAcknowledge(t *testing.T) { var buf bytes.Buffer bc := bytecounter.NewReader(&buf) - r := NewReader(bc, bc, func(count uint32) error { + r := NewReader(bc, bc, func(_ uint32) error { close(onAckCalled) return nil }) @@ -269,9 +269,9 @@ func TestReaderAcknowledge(t *testing.T) { } func FuzzReader(f *testing.F) { - f.Fuzz(func(t *testing.T, b []byte) { + f.Fuzz(func(_ *testing.T, b []byte) { br := bytecounter.NewReader(bytes.NewReader(b)) - r := NewReader(br, br, func(count uint32) error { + r := NewReader(br, br, func(_ uint32) error { return nil }) diff --git a/internal/protocols/websocket/serverconn.go b/internal/protocols/websocket/serverconn.go index f0e81922..c5fd3506 100644 --- a/internal/protocols/websocket/serverconn.go +++ b/internal/protocols/websocket/serverconn.go @@ -18,7 +18,7 @@ var ( ) var upgrader = websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { + CheckOrigin: func(_ *http.Request) bool { return true }, } diff --git a/internal/protocols/websocket/serverconn_test.go b/internal/protocols/websocket/serverconn_test.go index 8b40efb7..e6d5ce9d 100644 --- a/internal/protocols/websocket/serverconn_test.go +++ b/internal/protocols/websocket/serverconn_test.go @@ -39,7 +39,7 @@ func TestServerConn(t *testing.T) { defer res.Body.Close() defer c.Close() //nolint:errcheck - c.SetPingHandler(func(msg string) error { + c.SetPingHandler(func(_ string) error { close(pingReceived) return nil }) diff --git a/internal/record/agent_test.go b/internal/record/agent_test.go index 4e4dd3dc..9c394b6d 100644 --- a/internal/record/agent_test.go +++ b/internal/record/agent_test.go @@ -167,10 +167,10 @@ func TestAgent(t *testing.T) { SegmentDuration: 1 * time.Second, PathName: "mypath", Stream: stream, - OnSegmentCreate: func(fpath string) { + OnSegmentCreate: func(_ string) { segCreated <- struct{}{} }, - OnSegmentComplete: func(fpath string) { + OnSegmentComplete: func(_ string) { segDone <- struct{}{} }, Parent: &test.NilLogger{}, diff --git a/internal/servers/rtmp/server_test.go b/internal/servers/rtmp/server_test.go index 24a1b8ef..6bf292eb 100644 --- a/internal/servers/rtmp/server_test.go +++ b/internal/servers/rtmp/server_test.go @@ -258,7 +258,7 @@ func TestServerRead(t *testing.T) { }, }) - r.OnDataH264(func(pts time.Duration, au [][]byte) { + r.OnDataH264(func(_ time.Duration, au [][]byte) { require.Equal(t, [][]byte{ test.FormatH264.SPS, test.FormatH264.PPS, diff --git a/internal/servers/rtsp/server_test.go b/internal/servers/rtsp/server_test.go index 943910b6..c732d214 100644 --- a/internal/servers/rtsp/server_test.go +++ b/internal/servers/rtsp/server_test.go @@ -228,7 +228,7 @@ func TestServerRead(t *testing.T) { recv := make(chan struct{}) - reader.OnPacketRTPAny(func(m *description.Media, f format.Format, p *rtp.Packet) { + reader.OnPacketRTPAny(func(_ *description.Media, _ format.Format, p *rtp.Packet) { require.Equal(t, &rtp.Packet{ Header: rtp.Header{ Version: 2, diff --git a/internal/staticsources/hls/source.go b/internal/staticsources/hls/source.go index 7e9d2b87..bbffce65 100644 --- a/internal/staticsources/hls/source.go +++ b/internal/staticsources/hls/source.go @@ -123,7 +123,7 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error { }}, } - c.OnDataH26x(track, func(pts time.Duration, dts time.Duration, au [][]byte) { + c.OnDataH26x(track, func(pts time.Duration, _ time.Duration, au [][]byte) { stream.WriteUnit(medi, medi.Formats[0], &unit.H264{ Base: unit.Base{ NTP: time.Now(), @@ -144,7 +144,7 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error { }}, } - c.OnDataH26x(track, func(pts time.Duration, dts time.Duration, au [][]byte) { + c.OnDataH26x(track, func(pts time.Duration, _ time.Duration, au [][]byte) { stream.WriteUnit(medi, medi.Formats[0], &unit.H265{ Base: unit.Base{ NTP: time.Now(), diff --git a/internal/staticsources/rtsp/source_test.go b/internal/staticsources/rtsp/source_test.go index ebdb3e99..6741d0fd 100644 --- a/internal/staticsources/rtsp/source_test.go +++ b/internal/staticsources/rtsp/source_test.go @@ -69,12 +69,12 @@ func TestSource(t *testing.T) { StatusCode: base.StatusOK, }, stream, nil }, - onSetup: func(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { + onSetup: func(_ *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { return &base.Response{ StatusCode: base.StatusOK, }, stream, nil }, - onPlay: func(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { + onPlay: func(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { go func() { time.Sleep(100 * time.Millisecond) err := stream.WritePacketRTP(media0, &rtp.Packet{ @@ -195,7 +195,7 @@ func TestRTSPSourceNoPassword(t *testing.T) { StatusCode: base.StatusOK, }, stream, nil }, - onSetup: func(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { + onSetup: func(_ *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { go func() { time.Sleep(100 * time.Millisecond) err := stream.WritePacketRTP(media0, &rtp.Packet{ @@ -216,7 +216,7 @@ func TestRTSPSourceNoPassword(t *testing.T) { StatusCode: base.StatusOK, }, stream, nil }, - onPlay: func(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { + onPlay: func(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { return &base.Response{ StatusCode: base.StatusOK, }, nil @@ -263,12 +263,12 @@ func TestRTSPSourceRange(t *testing.T) { s := gortsplib.Server{ Handler: &testServer{ - onDescribe: func(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error) { + onDescribe: func(_ *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error) { return &base.Response{ StatusCode: base.StatusOK, }, stream, nil }, - onSetup: func(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { + onSetup: func(_ *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { return &base.Response{ StatusCode: base.StatusOK, }, stream, nil