update golangci-lint (#292)

This commit is contained in:
Alessandro Ros
2023-05-28 13:40:00 +02:00
committed by GitHub
parent b50151a0d6
commit 19dcd3e067
29 changed files with 50 additions and 57 deletions

View File

@@ -19,7 +19,7 @@ jobs:
- uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
version: v1.52.2
go-mod-tidy:
runs-on: ubuntu-20.04

View File

@@ -1,5 +1,5 @@
BASE_IMAGE = golang:1.20.1-alpine3.17
LINT_IMAGE = golangci/golangci-lint:v1.50.1
LINT_IMAGE = golangci/golangci-lint:v1.52.2
.PHONY: $(shell ls)

View File

@@ -481,7 +481,7 @@ func (c *Client) runInner() error {
req.res <- clientRes{res: res, err: err}
case req := <-c.play:
res, err := c.doPlay(req.ra, false)
res, err := c.doPlay(req.ra)
req.res <- clientRes{res: res, err: err}
case req := <-c.record:
@@ -607,7 +607,7 @@ func (c *Client) trySwitchingProtocol() error {
}
}
_, err = c.doPlay(c.lastRange, true)
_, err = c.doPlay(c.lastRange)
if err != nil {
return err
}
@@ -1423,7 +1423,7 @@ func (c *Client) SetupAll(medias media.Medias, baseURL *url.URL) error {
return nil
}
func (c *Client) doPlay(ra *headers.Range, isSwitchingProtocol bool) (*base.Response, error) {
func (c *Client) doPlay(ra *headers.Range) (*base.Response, error) {
err := c.checkState(map[clientState]struct{}{
clientStatePrePlay: {},
})

View File

@@ -126,8 +126,8 @@ func (cm *clientMedia) start() {
}
if cm.udpRTPListener != nil {
cm.udpRTPListener.start(cm.c.state == clientStatePlay)
cm.udpRTCPListener.start(cm.c.state == clientStatePlay)
cm.udpRTPListener.start()
cm.udpRTCPListener.start()
}
for _, ct := range cm.formats {
@@ -241,7 +241,7 @@ func (cm *clientMedia) readRTCPTCPPlay(payload []byte) error {
return nil
}
func (cm *clientMedia) readRTPTCPRecord(payload []byte) error {
func (cm *clientMedia) readRTPTCPRecord(_ []byte) error {
return nil
}
@@ -323,7 +323,7 @@ func (cm *clientMedia) readRTCPUDPPlay(payload []byte) error {
return nil
}
func (cm *clientMedia) readRTPUDPRecord(payload []byte) error {
func (cm *clientMedia) readRTPUDPRecord(_ []byte) error {
return nil
}

View File

@@ -153,11 +153,11 @@ func (u *clientUDPListener) port() int {
return u.pc.LocalAddr().(*net.UDPAddr).Port
}
func (u *clientUDPListener) start(forPlay bool) {
func (u *clientUDPListener) start() {
u.running = true
u.pc.SetReadDeadline(time.Time{})
u.readerDone = make(chan struct{})
go u.runReader(forPlay)
go u.runReader()
}
func (u *clientUDPListener) stop() {
@@ -165,7 +165,7 @@ func (u *clientUDPListener) stop() {
<-u.readerDone
}
func (u *clientUDPListener) runReader(forPlay bool) {
func (u *clientUDPListener) runReader() {
defer close(u.readerDone)
var readFunc func([]byte) error

View File

@@ -18,7 +18,7 @@ type AV1 struct {
Tier *int
}
func (f *AV1) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *AV1) unmarshal(payloadType uint8, _ string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
for key, val := range fmtp {

View File

@@ -13,7 +13,7 @@ type G711 struct {
MULaw bool
}
func (f *G711) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *G711) unmarshal(payloadType uint8, _ string, _ string, _ string, _ map[string]string) error {
f.MULaw = (payloadType == 0)
return nil
}

View File

@@ -10,7 +10,7 @@ import (
// Specification: https://datatracker.ietf.org/doc/html/rfc3551
type G722 struct{}
func (f *G722) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *G722) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
return nil
}

View File

@@ -57,20 +57,17 @@ type Generic struct {
RTPMa string
FMT map[string]string
// clock rate of the format. Filled automatically.
// clock rate of the format. Filled when calling Init().
ClockRat int
}
// Init computes the clock rate of the format. It it mandatory to call it.
// Init computes the clock rate of the format. It is mandatory to call it.
func (f *Generic) Init() error {
f.ClockRat, _ = findClockRate(f.PayloadTyp, f.RTPMa)
return nil
}
func (f *Generic) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
) error {
func (f *Generic) unmarshal(payloadType uint8, _ string, _ string, rtpmap string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
f.RTPMa = rtpmap
f.FMT = fmtp

View File

@@ -81,7 +81,7 @@ type H264 struct {
mutex sync.RWMutex
}
func (f *H264) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *H264) unmarshal(payloadType uint8, _ string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
for key, val := range fmtp {

View File

@@ -23,7 +23,7 @@ type H265 struct {
mutex sync.RWMutex
}
func (f *H265) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *H265) unmarshal(payloadType uint8, _ string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
for key, val := range fmtp {

View File

@@ -18,7 +18,7 @@ type LPCM struct {
ChannelCount int
}
func (f *LPCM) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *LPCM) unmarshal(payloadType uint8, clock string, codec string, _ string, _ map[string]string) error {
f.PayloadTyp = payloadType
switch codec {

View File

@@ -10,7 +10,7 @@ import (
// Specification: https://datatracker.ietf.org/doc/html/rfc2435
type MJPEG struct{}
func (f *MJPEG) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *MJPEG) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
return nil
}

View File

@@ -10,10 +10,7 @@ import (
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
type MPEG2Audio struct{}
func (f *MPEG2Audio) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
) error {
func (f *MPEG2Audio) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
return nil
}

View File

@@ -8,10 +8,7 @@ import (
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
type MPEG2Video struct{}
func (f *MPEG2Video) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
) error {
func (f *MPEG2Video) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
return nil
}

View File

@@ -27,8 +27,8 @@ type MPEG4AudioGeneric struct {
}
func (f *MPEG4AudioGeneric) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
payloadType uint8, _ string, _ string,
_ string, fmtp map[string]string,
) error {
f.PayloadTyp = payloadType

View File

@@ -21,8 +21,8 @@ type MPEG4AudioLATM struct {
}
func (f *MPEG4AudioLATM) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
payloadType uint8, _ string, _ string,
_ string, fmtp map[string]string,
) error {
f.PayloadTyp = payloadType
f.ProfileLevelID = 30 // default value defined by specification

View File

@@ -23,8 +23,8 @@ type MPEG4VideoES struct {
}
func (f *MPEG4VideoES) unmarshal(
payloadType uint8, clock string, codec string,
rtpmap string, fmtp map[string]string,
payloadType uint8, _ string, _ string,
_ string, fmtp map[string]string,
) error {
f.PayloadTyp = payloadType
f.ProfileLevelID = 1 // default value defined by specification

View File

@@ -8,7 +8,7 @@ import (
// Specification: https://datatracker.ietf.org/doc/html/rfc2250
type MPEGTS struct{}
func (f *MPEGTS) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *MPEGTS) unmarshal(_ uint8, _ string, _ string, _ string, _ map[string]string) error {
return nil
}

View File

@@ -17,7 +17,7 @@ type Opus struct {
IsStereo bool
}
func (f *Opus) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *Opus) unmarshal(payloadType uint8, clock string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
tmp := strings.SplitN(clock, "/", 2)

View File

@@ -18,7 +18,7 @@ type Vorbis struct {
Configuration []byte
}
func (f *Vorbis) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *Vorbis) unmarshal(payloadType uint8, clock string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
tmp := strings.SplitN(clock, "/", 2)

View File

@@ -17,7 +17,7 @@ type VP8 struct {
MaxFS *int
}
func (f *VP8) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *VP8) unmarshal(payloadType uint8, _ string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
for key, val := range fmtp {

View File

@@ -18,7 +18,7 @@ type VP9 struct {
ProfileID *int
}
func (f *VP9) unmarshal(payloadType uint8, clock string, codec string, rtpmap string, fmtp map[string]string) error {
func (f *VP9) unmarshal(payloadType uint8, _ string, _ string, _ string, fmtp map[string]string) error {
f.PayloadTyp = payloadType
for key, val := range fmtp {

View File

@@ -4,7 +4,7 @@ import (
"fmt"
)
func readKey(origstr string, str string, separator byte) (string, string) {
func readKey(str string, separator byte) (string, string) {
i := 0
for {
if i >= len(str) || str[i] == '=' || str[i] == separator {
@@ -47,7 +47,7 @@ func keyValParse(str string, separator byte) (map[string]string, error) {
for len(str) > 0 {
var k string
k, str = readKey(origstr, str, separator)
k, str = readKey(str, separator)
if len(k) > 0 {
if len(str) > 0 && str[0] == '=' {

View File

@@ -26,10 +26,10 @@ func getSessionID(header base.Header) string {
func mediasForSDP(
medias media.Medias,
streamMedias map[*media.Media]*serverStreamMedia,
contentBase *url.URL,
) media.Medias {
copy := make(media.Medias, len(medias))
newMedias := make(media.Medias, len(medias))
for i, medi := range medias {
mc := &media.Media{
Type: medi.Type,
@@ -47,9 +47,10 @@ func mediasForSDP(
u, _ := mc.URL(contentBase)
mc.Control = u.String()
copy[i] = mc
newMedias[i] = mc
}
return copy
return newMedias
}
type readReq struct {
@@ -294,7 +295,7 @@ func (sc *ServerConn) handleRequestInner(req *base.Request) (*base.Response, err
}
if stream != nil {
byts, _ := mediasForSDP(stream.medias, stream.streamMedias, req.URL).Marshal(multicast).Marshal()
byts, _ := mediasForSDP(stream.medias, req.URL).Marshal(multicast).Marshal()
res.Body = byts
}
}

View File

@@ -68,12 +68,12 @@ func (cr *serverConnReader) readFuncStandard() error {
cr.sc.nconn.SetReadDeadline(time.Time{})
for {
any, err := cr.sc.conn.ReadInterleavedFrameOrRequest()
what, err := cr.sc.conn.ReadInterleavedFrameOrRequest()
if err != nil {
return err
}
switch what := any.(type) {
switch what := what.(type) {
case *base.Request:
cres := make(chan error)
req := readReq{req: what, res: cres}

View File

@@ -66,7 +66,8 @@ func invalidURLAnnounceReq(t *testing.T, control string) base.Request {
MediaDescriptions: []*psdp.MediaDescription{medi.Marshal()},
}
byts, _ := sout.Marshal()
byts, err := sout.Marshal()
require.NoError(t, err)
return base.Request{
Method: base.Announce,

View File

@@ -240,7 +240,7 @@ func (sm *serverSessionMedia) readRTCPUDPRecord(payload []byte) error {
return nil
}
func (sm *serverSessionMedia) readRTPTCPPlay(payload []byte) error {
func (sm *serverSessionMedia) readRTPTCPPlay(_ []byte) error {
return nil
}

View File

@@ -323,7 +323,7 @@ type testServerErrMethodNotImplemented struct {
}
func (s *testServerErrMethodNotImplemented) OnDescribe(
ctx *ServerHandlerOnDescribeCtx,
_ *ServerHandlerOnDescribeCtx,
) (*base.Response, *ServerStream, error) {
return &base.Response{
StatusCode: base.StatusOK,
@@ -331,7 +331,7 @@ func (s *testServerErrMethodNotImplemented) OnDescribe(
}
func (s *testServerErrMethodNotImplemented) OnSetup(
ctx *ServerHandlerOnSetupCtx,
_ *ServerHandlerOnSetupCtx,
) (*base.Response, *ServerStream, error) {
return &base.Response{
StatusCode: base.StatusOK,