Skip to content

Commit

Permalink
use Go 1.21's binary.NativeEndian (#220)
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Fitzpatrick <brad@danga.com>
  • Loading branch information
bradfitz authored Jan 13, 2025
1 parent 13a521f commit fbb4dce
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
go-version: ["1.18", "1.19", "1.20"]
go-version: ["1.21", "1.22", "1.23"]
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 @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
go-version: ["1.18", "1.19", "1.20"]
go-version: ["1.21", "1.22", "1.23"]
runs-on: ubuntu-latest

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

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

steps:
Expand Down
5 changes: 2 additions & 3 deletions attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math"

"github.com/josharian/native"
"github.com/mdlayher/netlink/nlenc"
)

Expand Down Expand Up @@ -168,7 +167,7 @@ type AttributeDecoder struct {
func NewAttributeDecoder(b []byte) (*AttributeDecoder, error) {
ad := &AttributeDecoder{
// By default, use native byte order.
ByteOrder: native.Endian,
ByteOrder: binary.NativeEndian,

b: b,
}
Expand Down Expand Up @@ -485,7 +484,7 @@ type AttributeEncoder struct {

// NewAttributeEncoder creates an AttributeEncoder that encodes Attributes.
func NewAttributeEncoder() *AttributeEncoder {
return &AttributeEncoder{ByteOrder: native.Endian}
return &AttributeEncoder{ByteOrder: binary.NativeEndian}
}

// Uint8 encodes uint8 data into an Attribute specified by typ.
Expand Down
9 changes: 4 additions & 5 deletions attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"unsafe"

"github.com/google/go-cmp/cmp"
"github.com/josharian/native"
"github.com/mdlayher/netlink/nlenc"
)

Expand Down Expand Up @@ -565,8 +564,8 @@ func TestAttributeDecoderOK(t *testing.T) {
},
{
name: "uint-int native endian",
attrs: adEndianAttrs(native.Endian),
fn: adEndianTest(native.Endian),
attrs: adEndianAttrs(binary.NativeEndian),
fn: adEndianTest(binary.NativeEndian),
},
{
name: "uint-int little endian",
Expand Down Expand Up @@ -1017,8 +1016,8 @@ func TestAttributeEncoderOK(t *testing.T) {
},
{
name: "uint-int native endian",
attrs: adEndianAttrs(native.Endian),
fn: aeEndianTest(native.Endian),
attrs: adEndianAttrs(binary.NativeEndian),
fn: aeEndianTest(binary.NativeEndian),
},
{
name: "uint-int little endian",
Expand Down
3 changes: 1 addition & 2 deletions conn_linux_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/josharian/native"
"github.com/mdlayher/netlink"
"github.com/mdlayher/netlink/nltest"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -116,7 +115,7 @@ func TestConnReceiveErrorLinux(t *testing.T) {
}

func skipBigEndian(t *testing.T) {
if binary.ByteOrder(native.Endian) == binary.BigEndian {
if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
t.Skip("skipping test on big-endian system")
}
}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module github.com/mdlayher/netlink

go 1.18
go 1.21

require (
github.com/google/go-cmp v0.5.9
github.com/josharian/native v1.1.0
github.com/mdlayher/socket v0.4.1
golang.org/x/net v0.9.0
golang.org/x/sys v0.7.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
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.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
Expand Down
2 changes: 1 addition & 1 deletion internal/integration/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mdlayher/netlink/internal/integration

go 1.18
go 1.21

require (
github.com/google/go-cmp v0.5.9
Expand Down
1 change: 1 addition & 0 deletions internal/integration/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github.com/cilium/ebpf v0.10.0 h1:nk5HPMeoBXtOzbkZBWym+ZWq1GIiHUsBFXxwewXAHLQ=
github.com/cilium/ebpf v0.10.0/go.mod h1:DPiVdY/kT534dgc9ERmvP8mWA+9gvwgKfRvk4nNWnoE=
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.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
Expand Down
4 changes: 1 addition & 3 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"errors"
"reflect"
"testing"

"github.com/josharian/native"
)

func TestHeaderFlagsString(t *testing.T) {
Expand Down Expand Up @@ -476,7 +474,7 @@ func TestValidate(t *testing.T) {
}

func skipBigEndian(t *testing.T) {
if binary.ByteOrder(native.Endian) == binary.BigEndian {
if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
t.Skip("skipping test on big-endian system")
}
}
4 changes: 1 addition & 3 deletions nlenc/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ package nlenc

import (
"encoding/binary"

"github.com/josharian/native"
)

// NativeEndian returns the native byte order of this system.
func NativeEndian() binary.ByteOrder {
// TODO(mdlayher): consider deprecating and removing this function for v2.
return native.Endian
return binary.NativeEndian
}
3 changes: 1 addition & 2 deletions nltest/nltest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/josharian/native"
"github.com/mdlayher/netlink"
"github.com/mdlayher/netlink/nltest"
)
Expand Down Expand Up @@ -538,7 +537,7 @@ var noop = func(req []netlink.Message) ([]netlink.Message, error) {
}

func skipBigEndian(t *testing.T) {
if binary.ByteOrder(native.Endian) == binary.BigEndian {
if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
t.Skip("skipping test on big-endian system")
}
}

0 comments on commit fbb4dce

Please sign in to comment.