diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08e4272a8..b02428931 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 e06de4d3c..a3235bec2 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/internal/net/buffer_test.go b/internal/net/buffer_test.go index cf90d270f..e416dde53 100644 --- a/internal/net/buffer_test.go +++ b/internal/net/buffer_test.go @@ -125,7 +125,7 @@ func TestBuffer(t *testing.T) { equalUDPAddr(t, addr, raddr) // Until EOF. - if _, _, err = buffer.ReadFrom(packet); !errors.Is(io.EOF, err) { + if _, _, err = buffer.ReadFrom(packet); !errors.Is(err, io.EOF) { t.Fatalf("Unexpected err %v wanted io.EOF", err) } } @@ -148,7 +148,7 @@ func TestShortBuffer(t *testing.T) { packet := make([]byte, 3) var raddr net.Addr n, raddr, err = buffer.ReadFrom(packet) - if !errors.Is(io.ErrShortBuffer, err) { + if !errors.Is(err, io.ErrShortBuffer) { t.Fatalf("Unexpected err %v wanted io.ErrShortBuffer", err) } equalUDPAddr(t, nil, raddr) @@ -251,7 +251,7 @@ func TestBufferAsync(t *testing.T) { equalUDPAddr(t, addr, raddr) _, _, readErr := buffer.ReadFrom(packet) - if !errors.Is(io.EOF, readErr) { + if !errors.Is(readErr, io.EOF) { done <- fmt.Sprintf("Unexpected err %v wanted io.EOF", readErr) } else { close(done) diff --git a/pkg/crypto/ccm/ccm.go b/pkg/crypto/ccm/ccm.go index d6e6fc479..73476f219 100644 --- a/pkg/crypto/ccm/ccm.go +++ b/pkg/crypto/ccm/ccm.go @@ -74,14 +74,14 @@ func (c *ccm) Overhead() int { return int(c.M) } func (c *ccm) MaxLength() int { return maxlen(c.L, c.Overhead()) } func maxlen(l uint8, tagsize int) int { - max := (uint64(1) << (8 * l)) - 1 - if m64 := uint64(math.MaxInt64) - uint64(tagsize); l > 8 || max > m64 { - max = m64 // The maximum lentgh on a 64bit arch + mLen := (uint64(1) << (8 * l)) - 1 + if m64 := uint64(math.MaxInt64) - uint64(tagsize); l > 8 || mLen > m64 { + mLen = m64 // The maximum lentgh on a 64bit arch } - if max != uint64(int(max)) { + if mLen != uint64(int(mLen)) { return math.MaxInt32 - tagsize // We have only 32bit int's } - return int(max) + return int(mLen) } // MaxNonceLength returns the maximum nonce length for a given plaintext length.