Skip to content

Commit

Permalink
Merge pull request #7 from ti-mo/go-1.20-cleanup
Browse files Browse the repository at this point in the history
Bump to Go 1.20, all dependencies to latest, drop go-cmp
  • Loading branch information
ti-mo authored Oct 16, 2023
2 parents 3d7ebe2 + 3a27513 commit 1b4c9ec
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18, 1.19]
go-version: ["1.20", "1.21"]
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18, 1.19]
go-version: ["1.20", "1.21"]
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18, 1.19]
go-version: ["1.20", "1.21"]
runs-on: ubuntu-latest

steps:
Expand Down
20 changes: 5 additions & 15 deletions attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"strings"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -138,15 +137,9 @@ func TestAttributeMarshalAttributes(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

b, err := MarshalAttributes(tt.attrs)
if err != nil {
t.Fatalf("unexpected marshal error: %v", err)
}

if diff := cmp.Diff(tt.b, b); diff != "" {
t.Fatalf("unexpected marshal (-want +got):\n%s", diff)
}
require.NoError(t, err)
assert.Equal(t, tt.b, b, "unexpected marshal")
})
}
}
Expand Down Expand Up @@ -385,16 +378,13 @@ func TestAttributeMarshalTwoWay(t *testing.T) {
// Unmarshal binary content into nested structures
attrs, err := decodeAttributes(ad)
require.NoError(t, err)

assert.Empty(t, cmp.Diff(tt.attrs, attrs))

var b []byte
assert.Equal(t, tt.attrs, attrs, "unexpected decode")

// Attempt re-marshal into binary form
var b []byte
b, err = MarshalAttributes(tt.attrs)
require.NoError(t, err)

assert.Empty(t, cmp.Diff(tt.b, b))
assert.Equal(t, tt.b, b, "unexpected marshal")
})
}
}
Expand Down
21 changes: 11 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
module github.com/ti-mo/netfilter

go 1.18
go 1.20

require (
github.com/google/go-cmp v0.5.9
github.com/mdlayher/netlink v1.7.1
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.3.0
golang.org/x/sys v0.2.0
github.com/mdlayher/netlink v1.7.2
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
golang.org/x/sys v0.13.0
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/josharian/native v1.0.0 // indirect
github.com/mdlayher/socket v0.4.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
37 changes: 20 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/mdlayher/netlink v1.7.1 h1:FdUaT/e33HjEXagwELR8R3/KL1Fq5x3G5jgHLp/BTmg=
github.com/mdlayher/netlink v1.7.1/go.mod h1:nKO5CSjE/DJjVhk/TNp6vCE1ktVxEA8VEh8drhZzxsQ=
github.com/mdlayher/socket v0.4.0 h1:280wsy40IC9M9q1uPGcLBwXpcTQDtoGwVt+BNoITxIw=
github.com/mdlayher/socket v0.4.0/go.mod h1:xxFqz5GRCUN3UEOm9CZqEJsAbe1C8OwSK46NlmWuVoc=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 3 additions & 11 deletions header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package netfilter
import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"

"github.com/mdlayher/netlink"
Expand All @@ -22,19 +21,12 @@ func TestHeaderMarshalTwoWay(t *testing.T) {
refMsg := netlink.Message{Header: netlink.Header{Type: 0x087B}, Data: []byte{255, 1, 0, 2}}

var gotHdr Header
gotMsg := netlink.Message{Data: make([]byte, 4)}

assert.Nil(t, gotHdr.unmarshal(refMsg))
assert.Equal(t, refHdr, gotHdr, "unexpected unmarshal")

if diff := cmp.Diff(refHdr, gotHdr); diff != "" {
t.Fatalf("unexpected netfilter Header (-want, +got):\n %s", diff)
}

gotMsg := netlink.Message{Data: make([]byte, 4)}
assert.Nil(t, gotHdr.marshal(&gotMsg))

if diff := cmp.Diff(refMsg, gotMsg); diff != "" {
t.Fatalf("unexpected netlink Message (-want, +got):\n %s", diff)
}
assert.Equal(t, refMsg, gotMsg, "unexpected marshal")

// unmarshal error
assert.Equal(t, errMessageLen, gotHdr.unmarshal(netlink.Message{}))
Expand Down
14 changes: 3 additions & 11 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/pkg/errors"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -77,13 +76,8 @@ func TestMessageUnmarshalNetlink(t *testing.T) {

require.NoError(t, err)

if diff := cmp.Diff(tt.attrs, attrs); diff != "" {
t.Fatalf("unexpected attributes (-want, +got):\n%s", diff)
}

if diff := cmp.Diff(tt.h, h); diff != "" {
t.Fatalf("unexpected header (-want, +got):\n%s", diff)
}
assert.Equal(t, tt.attrs, attrs, "unexpected attributes")
assert.Equal(t, tt.h, h, "unexpected header")
})
}
}
Expand Down Expand Up @@ -147,9 +141,7 @@ func TestAttributeMarshalNetlink(t *testing.T) {
return
}

if diff := cmp.Diff(tt.msg, msg); diff != "" {
t.Fatalf("unexpected message (-want, +got):\n%s", diff)
}
assert.Equal(t, tt.msg, msg, "unexpected message")
})
}
}
Expand Down

0 comments on commit 1b4c9ec

Please sign in to comment.