diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 30d0782d..b5d90efd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,6 +12,7 @@ jobs: strategy: matrix: go: [ '1.18' ] + arch: [ '', '386' ] name: Go ${{ matrix.go }} steps: - uses: actions/checkout@v2 @@ -19,5 +20,9 @@ jobs: uses: actions/setup-go@v1 with: go-version: ${{ matrix.go }} + - name: Set GOARCH + run: | + echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV - run: go test -v -race -short ./... + if: env.GOARCH != '386' - run: go test -v ./... diff --git a/message.go b/message.go index 91fd1258..eb944d27 100644 --- a/message.go +++ b/message.go @@ -787,7 +787,7 @@ func (e *Encoder) Encode(m *Message) error { return annotatef(err, "encode") } n := len(s.data) - if n > int(maxSegmentSize) { + if int64(n) > int64(maxSegmentSize) { return errorf("encode: segment %d too large", i) } e.hdrbuf = appendUint32(e.hdrbuf, uint32(Size(n)/wordSize)) diff --git a/message_test.go b/message_test.go index e3db149c..12701185 100644 --- a/message_test.go +++ b/message_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "math" "testing" "testing/quick" @@ -873,6 +874,7 @@ func TestFirstSegmentMessage_MultiSegment(t *testing.T) { func TestNextAlloc(t *testing.T) { const max32 = 1<<31 - 8 const max64 = 1<<63 - 8 + const is64bit = int64(maxInt) == math.MaxInt64 tests := []struct { name string curr int64 @@ -885,7 +887,7 @@ func TestNextAlloc(t *testing.T) { {name: "first word, unaligned curr", curr: 13, max: max64, req: 8, ok: true}, {name: "second word", curr: 8, max: max64, req: 8, ok: true}, {name: "one byte pads to word", curr: 8, max: max64, req: 1, ok: true}, - {name: "max size", curr: 0, max: max64, req: 0xfffffff8, ok: true}, + {name: "max size", curr: 0, max: max64, req: 0xfffffff8, ok: is64bit}, {name: "max size + 1", curr: 0, max: max64, req: 0xfffffff9, ok: false}, {name: "max req", curr: 0, max: max64, req: 0xffffffff, ok: false}, {name: "max curr, request 0", curr: max64, max: max64, req: 0, ok: true},