diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1c63be9..8564b01 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,10 +14,11 @@ jobs: - "1.19" - "1.20" - "1.21" + - "1.22" name: "Go ${{ matrix.go }} build" steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: "${{ matrix.go }}" - run: "go version" @@ -29,14 +30,15 @@ jobs: name: "Test and lint" steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: "1.21" - - uses: golangci/golangci-lint-action@v3 + go-version: "1.22" + - uses: golangci/golangci-lint-action@v6 with: - version: "v1.55" + version: "v1.59" - run: "go test -v -race -coverprofile=coverage.txt -covermode=atomic ./netpunchlib/..." - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: + token: ${{ secrets.CODECOV_TOKEN }} # required files: ./coverage.txt verbose: true diff --git a/.golangci.yaml b/.golangci.yaml index 3a0c66d..ae7b80d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,30 +1,22 @@ linters: enable-all: true disable: - - wrapcheck - - paralleltest - - gomnd + # nice to be turned on - wsl - nlreturn - - depguard - - goerr113 # TODO: has to be turned on - - inamedparam - # disabled in golangci-lint v1.45.2 due to 1.18 - - contextcheck - - staticcheck # TODO: has to be turned on + - err113 + - mnd + - wrapcheck # deprecated - - interfacer - - maligned - - scopelint - - golint - - exhaustivestruct # since v1.46.0 - - varcheck # since v1.49.0 - - nosnakecase # since v1.48.1 - - deadcode # since v1.49.0 - - structcheck # since v1.49.0 - - ifshort # since v1.48.0 + - gomnd + - execinquery + # disabled because the Go version + - copyloopvar + - intrange linters-settings: + paralleltest: + ignore-missing: true cyclop: max-complexity: 20 funlen: @@ -42,6 +34,23 @@ linters-settings: - standard - default - prefix(github.com/michurin/netpunch/netpunchlib) + depguard: + rules: + regular: + files: + - !$test + allow: + - $gostd + - github.com/michurin/netpunch/netpunchlib + tests: + files: + - $test + allow: + - $gostd + - github.com/michurin/netpunch/netpunchlib + - github.com/stretchr/testify/assert + - github.com/stretchr/testify/require + - github.com/golang/mock/gomock issues: exclude-rules: diff --git a/go.mod b/go.mod index 36ce2d5..1e7e2d4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/golang/mock v1.6.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 ) require ( diff --git a/go.sum b/go.sum index 6c827da..8f27e55 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/netpunchlib/connection.go b/netpunchlib/connection.go index e3333c1..2b363f0 100644 --- a/netpunchlib/connection.go +++ b/netpunchlib/connection.go @@ -3,11 +3,11 @@ package netpunchlib import "net" type ConnectionReader interface { - ReadFromUDP([]byte) (int, *net.UDPAddr, error) + ReadFromUDP(data []byte) (int, *net.UDPAddr, error) } type ConnectionWriter interface { - WriteToUDP([]byte, *net.UDPAddr) (int, error) + WriteToUDP(data []byte, addr *net.UDPAddr) (int, error) } type ConnectionCloser interface { diff --git a/netpunchlib/mw_sign_test.go b/netpunchlib/mw_sign_test.go index d215faf..c773c26 100644 --- a/netpunchlib/mw_sign_test.go +++ b/netpunchlib/mw_sign_test.go @@ -51,7 +51,7 @@ func TestWriteToUDP_error(t *testing.T) { n, err := conn.WriteToUDP([]byte("data"), nil) assert.Equal(t, 0, n) - assert.Errorf(t, err, "TestErr") //nolint:testifylint + assert.Errorf(t, err, "TestErr") } func TestReadFromUDP_ok(t *testing.T) {