Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Go 1.21's binary.NativeEndian #220

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}
Loading