diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d96bc962..6d1d1904 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: - uses: golangci/golangci-lint-action@v2 with: - version: v1.38 + version: v1.40 mod-tidy: runs-on: ubuntu-20.04 diff --git a/.golangci.yml b/.golangci.yml index 5c7573c1..722bcea8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - bodyclose + - dupl - exportloopref - gochecknoinits - gocritic @@ -12,6 +13,7 @@ linters: - lll - prealloc - unconvert + - whitespace disable: - errcheck diff --git a/Makefile b/Makefile index fa06f903..88e42fbf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE_IMAGE = golang:1.16-alpine3.13 -LINT_IMAGE = golangci/golangci-lint:v1.38.0 +LINT_IMAGE = golangci/golangci-lint:v1.40 NODE_IMAGE = node:14-alpine3.13 .PHONY: $(shell ls) @@ -43,7 +43,7 @@ export DOCKERFILE_FORMAT format: echo "$$DOCKERFILE_FORMAT" | docker build -q . -f - -t temp docker run --rm -it -v $(PWD):/s -w /s temp \ - sh -c "find . -type f -name '*.go' | xargs gofumpt -l -w" + sh -c "gofumpt -l -w ." define DOCKERFILE_TEST ARG ARCH diff --git a/internal/conf/path.go b/internal/conf/path.go index 689fb727..b74021fa 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -189,7 +189,6 @@ func (pconf *PathConf) checkAndFillMissing(name string) error { if err != nil { return fmt.Errorf("'%s': %s", pconf.Fallback, err) } - } else { _, err := base.ParseURL(pconf.Fallback) if err != nil { diff --git a/internal/core/hls_muxer.go b/internal/core/hls_muxer.go index 2658d8e7..d413c3d4 100644 --- a/internal/core/hls_muxer.go +++ b/internal/core/hls_muxer.go @@ -280,7 +280,6 @@ func (r *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{}) videoTrackID = i h264Decoder = rtph264.NewDecoder() - } else if t.IsAAC() { if audioTrack != nil { return fmt.Errorf("can't read track %d with HLS: too many tracks", i+1) @@ -351,7 +350,6 @@ func (r *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{}) if err != nil { return err } - } else if audioTrack != nil && pair.trackID == audioTrackID { var pkt rtp.Packet err := pkt.Unmarshal(pair.buf) diff --git a/internal/core/path.go b/internal/core/path.go index 3db122c3..81399a90 100644 --- a/internal/core/path.go +++ b/internal/core/path.go @@ -474,7 +474,6 @@ func (pa *path) onDemandStartSource() { if pa.hasStaticSource() { pa.staticSourceCreate() pa.onDemandReadyTimer = time.NewTimer(time.Duration(pa.conf.SourceOnDemandStartTimeout)) - } else { pa.log(logger.Info, "runOnDemand command started") _, port, _ := net.SplitHostPort(pa.rtspAddress) diff --git a/internal/core/rtmp_conn.go b/internal/core/rtmp_conn.go index 4e34d0ab..78d3bb20 100644 --- a/internal/core/rtmp_conn.go +++ b/internal/core/rtmp_conn.go @@ -251,7 +251,6 @@ func (c *rtmpConn) runRead(ctx context.Context) error { videoTrack = t videoTrackID = i h264Decoder = rtph264.NewDecoder() - } else if t.IsAAC() { if audioTrack != nil { return fmt.Errorf("can't read track %d with RTMP: too many tracks", i+1) @@ -377,7 +376,6 @@ func (c *rtmpConn) runRead(ctx context.Context) error { if err != nil { return err } - } else if audioTrack != nil && pair.trackID == audioTrackID { var pkt rtp.Packet err := pkt.Unmarshal(pair.buf) diff --git a/internal/core/rtsp_server_test.go b/internal/core/rtsp_server_test.go index 5040041c..9752e0a6 100644 --- a/internal/core/rtsp_server_test.go +++ b/internal/core/rtsp_server_test.go @@ -59,7 +59,6 @@ func TestRTSPServerPublishRead(t *testing.T) { "readTimeout: 20s\n") require.Equal(t, true, ok) defer p.close() - } else { proto = "rtsps" port = "8555" @@ -262,7 +261,6 @@ func TestRTSPServerAuth(t *testing.T) { require.NoError(t, err) defer cnt2.close() require.Equal(t, 0, cnt2.wait()) - } else { cnt2, err := newContainer("vlc", "dest", []string{ "rtsp://testuser:test!$()*+.;<=>[]^_-{}@localhost:8554/test/stream", diff --git a/internal/hls/client.go b/internal/hls/client.go index e3c585c7..42b13d3a 100644 --- a/internal/hls/client.go +++ b/internal/hls/client.go @@ -885,7 +885,6 @@ func (c *Client) processSegment(innerCtx context.Context, byts []byte) error { dts -= c.clockStartPTS c.videoProc.process(data.PES.Data, pts, dts) - } else if c.audioPID != nil && data.PID == *c.audioPID { pts -= c.clockStartPTS