Skip to content

Commit

Permalink
Re-enable support for Go 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jan 25, 2022
1 parent 1a6044b commit 90fdcd5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
strategy:
matrix:
go-version:
- 1.16.x
- 1.17.x
steps:
- name: Set up Go
Expand Down
6 changes: 6 additions & 0 deletions export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package polyline

const (
MaxInt = maxInt
MinInt = minInt
)
4 changes: 2 additions & 2 deletions polyline.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func DecodeInt(buf []byte) (int, []byte, error) {
return 0, nil, err
case u&1 == 0:
return int(u >> 1), buf, nil
case u == math.MaxUint:
return math.MinInt, buf, nil
case u == maxUint:
return minInt, buf, nil
default:
return -int((u + 1) >> 1), buf, nil
}
Expand Down
12 changes: 12 additions & 0 deletions polyline_go116.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !go1.17
// +build !go1.17

package polyline

import "math"

const (
maxInt = math.MaxInt64
maxUint = math.MaxUint64
minInt = math.MinInt64
)
12 changes: 12 additions & 0 deletions polyline_go117.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build go1.17
// +build go1.17

package polyline

import "math"

const (
maxUint = math.MaxUint
maxInt = math.MaxInt
minInt = math.MinInt
)
8 changes: 4 additions & 4 deletions polyline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func TestInt(t *testing.T) {
{i: -75000, s: "nnqC"},
{i: 255200, s: "_mqN"},
{i: -550300, s: "vxq`@"},
{i: math.MaxInt, s: "}~~~~~~~~~~~N"},
{i: math.MaxInt - 1, s: "{~~~~~~~~~~~N"},
{i: math.MinInt + 1, s: "|~~~~~~~~~~~N"},
{i: math.MinInt, s: "~~~~~~~~~~~~N"},
{i: polyline.MaxInt, s: "}~~~~~~~~~~~N"},
{i: polyline.MaxInt - 1, s: "{~~~~~~~~~~~N"},
{i: polyline.MinInt + 1, s: "|~~~~~~~~~~~N"},
{i: polyline.MinInt, s: "~~~~~~~~~~~~N"},
} {
got, b, err := polyline.DecodeInt([]byte(tc.s))
assert.NoError(t, err)
Expand Down

0 comments on commit 90fdcd5

Please sign in to comment.