Skip to content

Commit 1b4c9ec

Browse files
authored
Merge pull request #7 from ti-mo/go-1.20-cleanup
Bump to Go 1.20, all dependencies to latest, drop go-cmp
2 parents 3d7ebe2 + 3a27513 commit 1b4c9ec

File tree

8 files changed

+45
-67
lines changed

8 files changed

+45
-67
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
go-version: [1.18, 1.19]
13+
go-version: ["1.20", "1.21"]
1414
runs-on: ubuntu-latest
1515

1616
steps:

.github/workflows/linux-integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
go-version: [1.18, 1.19]
13+
go-version: ["1.20", "1.21"]
1414
runs-on: ubuntu-latest
1515

1616
steps:

.github/workflows/linux-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
go-version: [1.18, 1.19]
13+
go-version: ["1.20", "1.21"]
1414
runs-on: ubuntu-latest
1515

1616
steps:

attribute_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/google/go-cmp/cmp"
87
"github.com/stretchr/testify/assert"
98
"github.com/stretchr/testify/require"
109
)
@@ -138,15 +137,9 @@ func TestAttributeMarshalAttributes(t *testing.T) {
138137

139138
for _, tt := range tests {
140139
t.Run(tt.name, func(t *testing.T) {
141-
142140
b, err := MarshalAttributes(tt.attrs)
143-
if err != nil {
144-
t.Fatalf("unexpected marshal error: %v", err)
145-
}
146-
147-
if diff := cmp.Diff(tt.b, b); diff != "" {
148-
t.Fatalf("unexpected marshal (-want +got):\n%s", diff)
149-
}
141+
require.NoError(t, err)
142+
assert.Equal(t, tt.b, b, "unexpected marshal")
150143
})
151144
}
152145
}
@@ -385,16 +378,13 @@ func TestAttributeMarshalTwoWay(t *testing.T) {
385378
// Unmarshal binary content into nested structures
386379
attrs, err := decodeAttributes(ad)
387380
require.NoError(t, err)
388-
389-
assert.Empty(t, cmp.Diff(tt.attrs, attrs))
390-
391-
var b []byte
381+
assert.Equal(t, tt.attrs, attrs, "unexpected decode")
392382

393383
// Attempt re-marshal into binary form
384+
var b []byte
394385
b, err = MarshalAttributes(tt.attrs)
395386
require.NoError(t, err)
396-
397-
assert.Empty(t, cmp.Diff(tt.b, b))
387+
assert.Equal(t, tt.b, b, "unexpected marshal")
398388
})
399389
}
400390
}

go.mod

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
module github.com/ti-mo/netfilter
22

3-
go 1.18
3+
go 1.20
44

55
require (
6-
github.com/google/go-cmp v0.5.9
7-
github.com/mdlayher/netlink v1.7.1
8-
github.com/pkg/errors v0.8.1
9-
github.com/stretchr/testify v1.3.0
10-
golang.org/x/sys v0.2.0
6+
github.com/mdlayher/netlink v1.7.2
7+
github.com/pkg/errors v0.9.1
8+
github.com/stretchr/testify v1.8.4
9+
golang.org/x/sys v0.13.0
1110
)
1211

1312
require (
14-
github.com/davecgh/go-spew v1.1.0 // indirect
15-
github.com/josharian/native v1.0.0 // indirect
16-
github.com/mdlayher/socket v0.4.0 // indirect
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/google/go-cmp v0.5.9 // indirect
15+
github.com/josharian/native v1.1.0 // indirect
16+
github.com/mdlayher/socket v0.4.1 // indirect
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
golang.org/x/net v0.2.0 // indirect
18+
golang.org/x/net v0.9.0 // indirect
1919
golang.org/x/sync v0.1.0 // indirect
20+
gopkg.in/yaml.v3 v3.0.1 // indirect
2021
)

go.sum

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
44
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5-
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
6-
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
7-
github.com/mdlayher/netlink v1.7.1 h1:FdUaT/e33HjEXagwELR8R3/KL1Fq5x3G5jgHLp/BTmg=
8-
github.com/mdlayher/netlink v1.7.1/go.mod h1:nKO5CSjE/DJjVhk/TNp6vCE1ktVxEA8VEh8drhZzxsQ=
9-
github.com/mdlayher/socket v0.4.0 h1:280wsy40IC9M9q1uPGcLBwXpcTQDtoGwVt+BNoITxIw=
10-
github.com/mdlayher/socket v0.4.0/go.mod h1:xxFqz5GRCUN3UEOm9CZqEJsAbe1C8OwSK46NlmWuVoc=
11-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
12-
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
5+
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
6+
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
7+
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
8+
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
9+
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
10+
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
11+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
12+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1313
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1414
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
15-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
16-
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
17-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
18-
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
19-
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
15+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
16+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
17+
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
18+
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
2019
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
2120
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
22-
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
23-
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
21+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
22+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
23+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
24+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
25+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
26+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

header_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package netfilter
33
import (
44
"testing"
55

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

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

2423
var gotHdr Header
25-
gotMsg := netlink.Message{Data: make([]byte, 4)}
26-
2724
assert.Nil(t, gotHdr.unmarshal(refMsg))
25+
assert.Equal(t, refHdr, gotHdr, "unexpected unmarshal")
2826

29-
if diff := cmp.Diff(refHdr, gotHdr); diff != "" {
30-
t.Fatalf("unexpected netfilter Header (-want, +got):\n %s", diff)
31-
}
32-
27+
gotMsg := netlink.Message{Data: make([]byte, 4)}
3328
assert.Nil(t, gotHdr.marshal(&gotMsg))
34-
35-
if diff := cmp.Diff(refMsg, gotMsg); diff != "" {
36-
t.Fatalf("unexpected netlink Message (-want, +got):\n %s", diff)
37-
}
29+
assert.Equal(t, refMsg, gotMsg, "unexpected marshal")
3830

3931
// unmarshal error
4032
assert.Equal(t, errMessageLen, gotHdr.unmarshal(netlink.Message{}))

message_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/pkg/errors"
77

8-
"github.com/google/go-cmp/cmp"
98
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
1110

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

7877
require.NoError(t, err)
7978

80-
if diff := cmp.Diff(tt.attrs, attrs); diff != "" {
81-
t.Fatalf("unexpected attributes (-want, +got):\n%s", diff)
82-
}
83-
84-
if diff := cmp.Diff(tt.h, h); diff != "" {
85-
t.Fatalf("unexpected header (-want, +got):\n%s", diff)
86-
}
79+
assert.Equal(t, tt.attrs, attrs, "unexpected attributes")
80+
assert.Equal(t, tt.h, h, "unexpected header")
8781
})
8882
}
8983
}
@@ -147,9 +141,7 @@ func TestAttributeMarshalNetlink(t *testing.T) {
147141
return
148142
}
149143

150-
if diff := cmp.Diff(tt.msg, msg); diff != "" {
151-
t.Fatalf("unexpected message (-want, +got):\n%s", diff)
152-
}
144+
assert.Equal(t, tt.msg, msg, "unexpected message")
153145
})
154146
}
155147
}

0 commit comments

Comments
 (0)