diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9b2497d..afd7e6b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,9 +17,9 @@ jobs: with: go-version: "1.24" - - uses: golangci/golangci-lint-action@v3 + - uses: golangci/golangci-lint-action@v8 with: - version: v1.64.5 + version: v2.1.6 go-mod-tidy: runs-on: ubuntu-22.04 diff --git a/.golangci.yml b/.golangci.yml index 4bfbdcf..e10b982 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,73 +1,75 @@ +version: "2" + linters: enable: - asciicheck - bidichk - bodyclose - #- contextcheck - copyloopvar - dupl - errorlint - gochecknoinits - gocritic - - gofmt - - gofumpt - lll - misspell - nilerr - prealloc - predeclared + - reassign - revive - usestdlibvars - unconvert - #- usetesting - tparallel - wastedassign - whitespace -issues: - exclude-use-default: false + settings: + errcheck: + exclude-functions: + - io.Copy + - (io.Closer).Close + - (io.Writer).Write + - (hash.Hash).Write + - (net.Conn).Close + - (net.Conn).SetReadDeadline + - (net.Conn).SetWriteDeadline + - (*net.TCPConn).SetKeepAlive + - (*net.TCPConn).SetKeepAlivePeriod + - (*net.TCPConn).SetNoDelay + - (net.Listener).Close + - (net.PacketConn).Close + - (net.PacketConn).SetReadDeadline + - (net.PacketConn).SetWriteDeadline + - (net/http.ResponseWriter).Write + - (*net/http.Server).Serve + - (*net/http.Server).ServeTLS + - (*net/http.Server).Shutdown + - os.Chdir + - os.Mkdir + - os.MkdirAll + - os.Remove + - os.RemoveAll + - os.Setenv + - os.Unsetenv + - (*os.File).WriteString + - (*os.File).Close + - (github.com/datarhei/gosrt.Conn).Close + - (github.com/datarhei/gosrt.Conn).SetReadDeadline + - (github.com/datarhei/gosrt.Conn).SetWriteDeadline + - (*github.com/bluenviron/gortsplib/v4.Client).Close + - (*github.com/bluenviron/gortsplib/v4.Server).Close + - (*github.com/bluenviron/gortsplib/v4.ServerSession).Close + - (*github.com/bluenviron/gortsplib/v4.ServerStream).Close + - (*github.com/bluenviron/gortsplib/v4.ServerConn).Close -linters-settings: - errcheck: - exclude-functions: - - io.Copy - - (io.Closer).Close - - (io.Writer).Write - - (hash.Hash).Write - - (net.Conn).Close - - (net.Conn).SetReadDeadline - - (net.Conn).SetWriteDeadline - - (*net.TCPConn).SetKeepAlive - - (*net.TCPConn).SetKeepAlivePeriod - - (*net.TCPConn).SetNoDelay - - (net.Listener).Close - - (net.PacketConn).Close - - (net.PacketConn).SetReadDeadline - - (net.PacketConn).SetWriteDeadline - - (net/http.ResponseWriter).Write - - (*net/http.Server).Serve - - (*net/http.Server).ServeTLS - - (*net/http.Server).Shutdown - - os.Chdir - - os.Mkdir - - os.MkdirAll - - os.Remove - - os.RemoveAll - - os.Setenv - - os.Unsetenv - - (*os.File).WriteString - - (*os.File).Close - - (github.com/datarhei/gosrt.Conn).Close - - (github.com/datarhei/gosrt.Conn).SetReadDeadline - - (github.com/datarhei/gosrt.Conn).SetWriteDeadline - - (*github.com/bluenviron/gortsplib/v4.Client).Close - - (*github.com/bluenviron/gortsplib/v4.Server).Close - - (*github.com/bluenviron/gortsplib/v4.ServerSession).Close - - (*github.com/bluenviron/gortsplib/v4.ServerStream).Close - - (*github.com/bluenviron/gortsplib/v4.ServerConn).Close + govet: + enable-all: true + disable: + - fieldalignment + - reflectvaluecompare - govet: - enable-all: true - disable: - - fieldalignment - - reflectvaluecompare +formatters: + enable: + - gofmt + - gofumpt + - goimports diff --git a/Makefile b/Makefile index 7f40bd6..f2efe9c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BASE_IMAGE = golang:1.24-alpine3.20 -LINT_IMAGE = golangci/golangci-lint:v1.64.5 +LINT_IMAGE = golangci/golangci-lint:v2.1.6 .PHONY: $(shell ls) diff --git a/internal/mp4/codec_box.go b/internal/mp4/codec_box.go index c0c792c..bb9630b 100644 --- a/internal/mp4/codec_box.go +++ b/internal/mp4/codec_box.go @@ -442,7 +442,7 @@ func WriteCodecBoxes(w *Writer, codec mp4.Codec, trackID int, info *CodecInfo, a return err } - enc, _ := codec.Config.Marshal() + enc, _ := codec.Marshal() _, err = w.WriteBox(&4.Esds{ // Descriptors: []amp4.Descriptor{ diff --git a/pkg/codecs/av1/sequence_header.go b/pkg/codecs/av1/sequence_header.go index ecbdccb..e2f0a78 100644 --- a/pkg/codecs/av1/sequence_header.go +++ b/pkg/codecs/av1/sequence_header.go @@ -144,13 +144,15 @@ func (c *SequenceHeader_ColorConfig) unmarshal(seqProfile uint8, buf []byte, pos return err } - switch { - case seqProfile == 0: + switch seqProfile { + case 0: c.SubsamplingX = true c.SubsamplingY = true - case seqProfile == 1: + + case 1: c.SubsamplingX = false c.SubsamplingY = false + default: if c.BitDepth == 12 { c.SubsamplingX, err = bits.ReadFlag(buf, pos) diff --git a/pkg/codecs/h265/dts_extractor.go b/pkg/codecs/h265/dts_extractor.go index e26fc6d..0632141 100644 --- a/pkg/codecs/h265/dts_extractor.go +++ b/pkg/codecs/h265/dts_extractor.go @@ -114,9 +114,11 @@ func getPTSDTSDiff(buf []byte, sps *SPS, pps *PPS) (uint32, error) { var v uint32 if sliceType == 0 { // B-frame - if typ == NALUType_TRAIL_N || typ == NALUType_RASL_N { + switch typ { + case NALUType_TRAIL_N, NALUType_RASL_N: v = sps.MaxNumReorderPics[0] - uint32(len(rps.DeltaPocS1)) - } else if typ == NALUType_TRAIL_R || typ == NALUType_RASL_R { + + case NALUType_TRAIL_R, NALUType_RASL_R: if len(rps.DeltaPocS0) == 0 { return 0, fmt.Errorf("invalid DeltaPocS0") } diff --git a/pkg/codecs/jpeg/define_quantization_table.go b/pkg/codecs/jpeg/define_quantization_table.go index b141fc6..d31d115 100644 --- a/pkg/codecs/jpeg/define_quantization_table.go +++ b/pkg/codecs/jpeg/define_quantization_table.go @@ -23,7 +23,7 @@ func (m *DefineQuantizationTable) Unmarshal(buf []byte) error { precision := buf[0] >> 4 buf = buf[1:] if precision != 0 { - return fmt.Errorf("Precision %d is not supported", precision) + return fmt.Errorf("precision %d is not supported", precision) } if len(buf) < 64 { diff --git a/pkg/formats/fmp4/parts.go b/pkg/formats/fmp4/parts.go index d4f4434..f0de8f9 100644 --- a/pkg/formats/fmp4/parts.go +++ b/pkg/formats/fmp4/parts.go @@ -103,7 +103,7 @@ func (ps *Parts) Unmarshal(byts []byte) error { } tfdt = box.(*amp4.Tfdt) - if tfdt.FullBox.Version != 1 { + if tfdt.Version != 1 { return nil, fmt.Errorf("unsupported tfdt version") } diff --git a/pkg/formats/mpegts/writer.go b/pkg/formats/mpegts/writer.go index f1bd5e7..6f9fd1f 100644 --- a/pkg/formats/mpegts/writer.go +++ b/pkg/formats/mpegts/writer.go @@ -211,9 +211,9 @@ func (w *Writer) WriteMPEG4Audio( for i, au := range aus { pkts[i] = &mpeg4audio.ADTSPacket{ - Type: aacCodec.Config.Type, + Type: aacCodec.Type, SampleRate: aacCodec.SampleRate, - ChannelCount: aacCodec.Config.ChannelCount, + ChannelCount: aacCodec.ChannelCount, AU: au, } }