Skip to content

Commit

Permalink
chore: don't export NativeEndian variable
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Mar 15, 2024
1 parent e8dd102 commit 85b6e06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions pgxgeom.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ type binaryScanPlan struct{}
// [github.com/twpayne/go-geom.T] types in text format.
type textScanPlan struct{}

// NativeEndian is the host's native byte order. We have to determine this with
// nativeEndian is the host's native byte order. We have to determine this with
// a runtime test in init() because binary.NativeEndian is a separate value to
// binary.LittleEndian and binary.BigEndian.
var NativeEndian binary.ByteOrder
var nativeEndian binary.ByteOrder

func init() {
data := []byte{0, 1, 2, 3, 4, 5, 6, 7}
switch binary.NativeEndian.Uint64(data) {
case binary.LittleEndian.Uint64(data):
NativeEndian = binary.LittleEndian
nativeEndian = binary.LittleEndian
case binary.BigEndian.Uint64(data):
NativeEndian = binary.BigEndian
nativeEndian = binary.BigEndian
default:
panic("unsupported byte order")
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (p binaryEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err erro
if !ok {
return buf, errors.ErrUnsupported
}
data, err := ewkb.Marshal(g, NativeEndian)
data, err := ewkb.Marshal(g, nativeEndian)
if err != nil {
return buf, err
}
Expand All @@ -141,7 +141,7 @@ func (p textEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error)
if !ok {
return buf, errors.ErrUnsupported
}
data, err := ewkb.Marshal(g, NativeEndian)
data, err := ewkb.Marshal(g, nativeEndian)
if err != nil {
return buf, err
}
Expand Down
3 changes: 2 additions & 1 deletion pgxgeom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pgxgeom_test

import (
"context"
"encoding/binary"
"strconv"
"testing"

Expand Down Expand Up @@ -90,7 +91,7 @@ func TestCodecScanValue(t *testing.T) {

func mustEWKB(tb testing.TB, g geom.T) []byte {
tb.Helper()
data, err := ewkb.Marshal(g, pgxgeom.NativeEndian)
data, err := ewkb.Marshal(g, binary.LittleEndian)
assert.NoError(tb, err)
return data
}
Expand Down

0 comments on commit 85b6e06

Please sign in to comment.