diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08e4272..b024289 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -33,7 +33,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -41,5 +41,5 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: "1.22" # auto-update/latest-go-version + go-version: "1.23" # auto-update/latest-go-version secrets: inherit diff --git a/.golangci.yml b/.golangci.yml index e06de4d..a3235be 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,9 @@ # SPDX-FileCopyrightText: 2023 The Pion community # SPDX-License-Identifier: MIT +run: + timeout: 5m + linters-settings: govet: enable: @@ -48,7 +51,7 @@ linters: - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter - godox # Tool for detection of FIXME, TODO and other comment keywords - - goerr113 # Golang linter to check the errors handling expressions + - err113 # Golang linter to check the errors handling expressions - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern @@ -83,17 +86,14 @@ linters: - depguard # Go linter that checks if package imports are in a list of acceptable packages - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - - exhaustivestruct # Checks if all struct's fields are initialized - funlen # Tool for detection of long functions - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period - gomnd # An analyzer to detect magic numbers. - - ifshort # Checks that your code uses short syntax for if-statements whenever possible - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines - maintidx # maintidx measures the maintainability index of each function. - makezero # Finds slice declarations with non-zero initial length - - maligned # Tool to detect Go structs that would take less memory if their fields were sorted - nakedret # Finds naked returns in functions greater than a specified function length - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity diff --git a/codecs/av1_packet.go b/codecs/av1_packet.go index bcea690..84c6c99 100644 --- a/codecs/av1_packet.go +++ b/codecs/av1_packet.go @@ -61,7 +61,7 @@ func (p *AV1Payloader) Payload(mtu uint16, payload []byte) (payloads [][]byte) { metadataSize += leb128Size + len(p.sequenceHeader) } - out := make([]byte, min(int(mtu), payloadDataRemaining+metadataSize)) + out := make([]byte, minInt(int(mtu), payloadDataRemaining+metadataSize)) outOffset := av1PayloaderHeadersize out[0] = obuCount << wBitshift diff --git a/codecs/common.go b/codecs/common.go index e807a0a..5b7dd14 100644 --- a/codecs/common.go +++ b/codecs/common.go @@ -3,7 +3,7 @@ package codecs -func min(a, b int) int { +func minInt(a, b int) int { if a < b { return a } diff --git a/codecs/common_test.go b/codecs/common_test.go index 7f0e38a..4c1f393 100644 --- a/codecs/common_test.go +++ b/codecs/common_test.go @@ -8,17 +8,17 @@ import ( ) func TestCommon_Min(t *testing.T) { - res := min(1, -1) + res := minInt(1, -1) if res != -1 { t.Fatal("Error: -1 < 1") } - res = min(1, 2) + res = minInt(1, 2) if res != 1 { t.Fatal("Error: 1 < 2") } - res = min(3, 3) + res = minInt(3, 3) if res != 3 { t.Fatal("Error: 3 == 3") } diff --git a/codecs/h264_packet.go b/codecs/h264_packet.go index 973a831..227cb9d 100644 --- a/codecs/h264_packet.go +++ b/codecs/h264_packet.go @@ -138,12 +138,12 @@ func (p *H264Payloader) Payload(mtu uint16, payload []byte) [][]byte { naluLength := len(nalu) - naluIndex naluRemaining := naluLength - if min(maxFragmentSize, naluRemaining) <= 0 { + if minInt(maxFragmentSize, naluRemaining) <= 0 { return } for naluRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, naluRemaining) + currentFragmentSize := minInt(maxFragmentSize, naluRemaining) out := make([]byte, fuaHeaderSize+currentFragmentSize) // +---------------+ diff --git a/codecs/vp8_packet.go b/codecs/vp8_packet.go index 4ddd15b..87560ab 100644 --- a/codecs/vp8_packet.go +++ b/codecs/vp8_packet.go @@ -56,12 +56,12 @@ func (p *VP8Payloader) Payload(mtu uint16, payload []byte) [][]byte { var payloads [][]byte // Make sure the fragment/payload size is correct - if min(maxFragmentSize, payloadDataRemaining) <= 0 { + if minInt(maxFragmentSize, payloadDataRemaining) <= 0 { return payloads } first := true for payloadDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) out := make([]byte, usingHeaderSize+currentFragmentSize) if first { diff --git a/codecs/vp9_packet.go b/codecs/vp9_packet.go index 98920be..e2ffab7 100644 --- a/codecs/vp9_packet.go +++ b/codecs/vp9_packet.go @@ -81,12 +81,12 @@ func (p *VP9Payloader) payloadFlexible(mtu uint16, payload []byte) [][]byte { payloadDataIndex := 0 var payloads [][]byte - if min(maxFragmentSize, payloadDataRemaining) <= 0 { + if minInt(maxFragmentSize, payloadDataRemaining) <= 0 { return [][]byte{} } for payloadDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) out := make([]byte, headerSize+currentFragmentSize) out[0] = 0x90 // F=1, I=1 @@ -149,7 +149,7 @@ func (p *VP9Payloader) payloadNonFlexible(mtu uint16, payload []byte) [][]byte { } maxFragmentSize := int(mtu) - headerSize - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) if currentFragmentSize <= 0 { return [][]byte{} } diff --git a/header_extension.go b/header_extension.go index fe54215..cdb16bd 100644 --- a/header_extension.go +++ b/header_extension.go @@ -163,7 +163,7 @@ type TwoByteHeaderExtension struct { // Set sets the extension payload for the specified ID. func (e *TwoByteHeaderExtension) Set(id uint8, buf []byte) error { - if id < 1 || id > 255 { + if id < 1 { return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderIDRange, id) } if len(buf) > 255 { diff --git a/packet.go b/packet.go index 61d341d..e74d48d 100644 --- a/packet.go +++ b/packet.go @@ -383,7 +383,7 @@ func (h *Header) SetExtension(id uint8, payload []byte) error { //nolint:gocogni } // RFC 8285 RTP Two Byte Header Extension case extensionProfileTwoByte: - if id < 1 || id > 255 { + if id < 1 { return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderIDRange, id) } if len(payload) > 255 {