update golangci-lint

This commit is contained in:
aler9 2021-03-20 14:14:41 +01:00
parent e5f9e80259
commit c979217e0d
10 changed files with 23 additions and 31 deletions

View File

@ -17,7 +17,7 @@ jobs:
- uses: golangci/golangci-lint-action@v2
with:
version: v1.33
version: v1.38
go-mod-tidy:
name: go-mod-tidy

View File

@ -1,6 +1,7 @@
linters:
enable:
- gocritic
- gofmt
- golint
- misspell

View File

@ -1,6 +1,6 @@
BASE_IMAGE = golang:1.15-alpine3.12
LINT_IMAGE = golangci/golangci-lint:v1.33.0
LINT_IMAGE = golangci/golangci-lint:v1.38.0
.PHONY: $(shell ls)

View File

@ -180,8 +180,7 @@ func (c *Client) runRead() {
res := <-resc
if res.Err != nil {
switch res.Err.(type) {
case client.ErrAuthCritical:
if _, ok := res.Err.(client.ErrAuthCritical); ok {
// wait some seconds to stop brute force attacks
select {
case <-time.After(pauseAfterAuthError):
@ -453,8 +452,7 @@ func (c *Client) runPublish() {
res := <-resc
if res.Err != nil {
switch res.Err.(type) {
case client.ErrAuthCritical:
if _, ok := res.Err.(client.ErrAuthCritical); ok {
// wait some seconds to stop brute force attacks
select {
case <-time.After(pauseAfterAuthError):

View File

@ -157,7 +157,7 @@ paths:
encryptedConf := func() string {
var secretKey [32]byte
copy(secretKey[:], key[:])
copy(secretKey[:], key)
var nonce [24]byte
if _, err := io.ReadFull(rand.Reader, nonce[:]); err != nil {

View File

@ -120,10 +120,11 @@ func (pconf *PathConf) fillAndCheck(name string) error {
pconf.Source = "record"
}
if pconf.Source == "record" {
switch {
case pconf.Source == "record":
} else if strings.HasPrefix(pconf.Source, "rtsp://") ||
strings.HasPrefix(pconf.Source, "rtsps://") {
case strings.HasPrefix(pconf.Source, "rtsp://") ||
strings.HasPrefix(pconf.Source, "rtsps://"):
if pconf.Regexp != nil {
return fmt.Errorf("a path with a regular expression (or path 'all') cannot have a RTSP source; use another path")
}
@ -161,7 +162,7 @@ func (pconf *PathConf) fillAndCheck(name string) error {
return fmt.Errorf("unsupported protocol '%s'", pconf.SourceProtocol)
}
} else if strings.HasPrefix(pconf.Source, "rtmp://") {
case strings.HasPrefix(pconf.Source, "rtmp://"):
if pconf.Regexp != nil {
return fmt.Errorf("a path with a regular expression (or path 'all') cannot have a RTMP source; use another path")
}
@ -183,7 +184,7 @@ func (pconf *PathConf) fillAndCheck(name string) error {
}
}
} else if pconf.Source == "redirect" {
case pconf.Source == "redirect":
if pconf.SourceRedirect == "" {
return fmt.Errorf("source redirect must be filled")
}
@ -193,7 +194,7 @@ func (pconf *PathConf) fillAndCheck(name string) error {
return fmt.Errorf("'%s' is not a valid RTSP url", pconf.SourceRedirect)
}
} else {
default:
return fmt.Errorf("invalid source: '%s'", pconf.Source)
}

View File

@ -12,8 +12,7 @@ import (
func load(env map[string]string, envKey string, rv reflect.Value) error {
rt := rv.Type()
switch rt {
case reflect.TypeOf(time.Duration(0)):
if rt == reflect.TypeOf(time.Duration(0)) {
if ev, ok := env[envKey]; ok {
d, err := time.ParseDuration(ev)
if err != nil {

View File

@ -556,12 +556,10 @@ func (pa *Path) fixedPublisherStart() {
pa.sourceState = sourceStateWaitingDescribe
}
} else {
// reset timer
if pa.sourceCloseTimerStarted {
pa.sourceCloseTimer.Stop()
pa.sourceCloseTimer = time.NewTimer(pa.conf.SourceOnDemandCloseAfter)
}
} else if pa.sourceCloseTimerStarted {
pa.sourceCloseTimer.Stop()
pa.sourceCloseTimer = time.NewTimer(pa.conf.SourceOnDemandCloseAfter)
}
}
@ -579,12 +577,10 @@ func (pa *Path) fixedPublisherStart() {
pa.sourceState = sourceStateWaitingDescribe
}
} else {
// reset timer
if pa.runOnDemandCloseTimerStarted {
pa.runOnDemandCloseTimer.Stop()
pa.runOnDemandCloseTimer = time.NewTimer(pa.conf.RunOnDemandCloseAfter)
}
} else if pa.runOnDemandCloseTimerStarted {
pa.runOnDemandCloseTimer.Stop()
pa.runOnDemandCloseTimer = time.NewTimer(pa.conf.RunOnDemandCloseAfter)
}
}
}

View File

@ -68,8 +68,7 @@ func ReadMetadata(conn *Conn) (*gortsplib.Track, *gortsplib.Track, error) {
}
case string:
switch vt {
case "avc1":
if vt == "avc1" {
return true, nil
}
}
@ -97,8 +96,7 @@ func ReadMetadata(conn *Conn) (*gortsplib.Track, *gortsplib.Track, error) {
}
case string:
switch vt {
case "mp4a":
if vt == "mp4a" {
return true, nil
}
}

View File

@ -421,8 +421,7 @@ func TestClientRTSPAutomaticProtocol(t *testing.T) {
require.Equal(t, true, ok)
defer p.close()
switch source {
case "ffmpeg":
if source == "ffmpeg" {
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",