From 81e8b0422558af7894837ff387751a6a52fbd7c3 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Fri, 22 Sep 2023 20:02:05 +0900 Subject: [PATCH 1/2] run test on 32-bit platforms --- .github/workflows/test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3bc013..719d3f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,11 +19,19 @@ jobs: - "1.19" - "1.18" goexperiment: [""] + goarch: + - amd64 include: # test with GOEXPERIMENT=loopvar # https://github.com/golang/go/wiki/LoopvarExperiment - go: "1.21" goexperiment: "loopvar" + goarch: amd64 + + # test on 32-bit platforms + - go: "1.21" + goexperiment: "loopvar" + goarch: "386" steps: - uses: actions/checkout@v4 @@ -37,6 +45,7 @@ jobs: go test -v -coverprofile=profile.cov ./... env: GOEXPERIMENT: ${{ matrix.goexperiment }} + GOARCH: ${{ matrix.goarch }} - uses: shogo82148/actions-goveralls@v1 with: From f99ae5cd55ef1d87359d2e63f0959a658385efe4 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Fri, 22 Sep 2023 20:10:58 +0900 Subject: [PATCH 2/2] fix compile errors on 32-bit platforms --- internal/jsonutils/decode_test.go | 12 ++++++------ jwk/rsa.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/jsonutils/decode_test.go b/internal/jsonutils/decode_test.go index b6a70be..98d5f1d 100644 --- a/internal/jsonutils/decode_test.go +++ b/internal/jsonutils/decode_test.go @@ -582,8 +582,8 @@ func TestDecoder_GetInt64(t *testing.T) { if !ok { t.Error("want ok, but not") } - if v != 9223372036854775807 { - t.Errorf("unexpected value, want %d, got %d", 9223372036854775807, v) + if got, want := v, int64(9223372036854775807); got != want { + t.Errorf("unexpected value, want %d, got %d", want, got) } if err := d.Err(); err != nil { t.Fatal(err) @@ -594,8 +594,8 @@ func TestDecoder_GetInt64(t *testing.T) { if !ok { t.Error("want ok, but not") } - if v != 9007199254740991 { - t.Errorf("unexpected value, want %d, got %d", 9007199254740991, v) + if got, want := v, int64(9007199254740991); got != want { + t.Errorf("unexpected value, want %d, got %d", want, got) } if err := d.Err(); err != nil { t.Fatal(err) @@ -654,8 +654,8 @@ func TestDecoder_MustInt64(t *testing.T) { d = NewDecoder("jsonutils", raw) v := d.MustInt64("integer") - if v != 9223372036854775807 { - t.Errorf("unexpected value: want %d, got %d", 9223372036854775807, v) + if got, want := v, int64(9223372036854775807); got != want { + t.Errorf("unexpected value: want %d, got %d", want, got) } if err := d.Err(); err != nil { t.Fatal(err) diff --git a/jwk/rsa.go b/jwk/rsa.go index 97f0470..400c3ea 100644 --- a/jwk/rsa.go +++ b/jwk/rsa.go @@ -165,7 +165,7 @@ func validateRSAPublicKey(key *rsa.PublicKey) error { if key.N == nil || key.N.Sign() <= 0 { return errors.New("jwk: invalid rsa modulus") } - if key.E < 2 || key.E > 1<<32-1 { + if key.E < 2 || key.E > math.MaxInt32 { return errors.New("jwk: invalid rsa public exponent") } return nil