Skip to content

Commit 26f1977

Browse files
committed
upgrade golangci-lint and fix errors
1 parent 0afc8ab commit 26f1977

File tree

14 files changed

+54
-45
lines changed

14 files changed

+54
-45
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
name: lint
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v6
1515

1616
- name: Setup Go
17-
uses: actions/setup-go@v5
17+
uses: actions/setup-go@v6
1818
with:
1919
go-version-file: go.mod
2020
check-latest: true
2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v3
22+
uses: golangci/golangci-lint-action@v9.2.0
2323
with:
24-
version: v1.50
24+
version: v2.11.4

clip/clip.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ func ring(box orb.Bound, in orb.Ring) orb.Ring {
9191
f := in[0]
9292
l := in[len(in)-1]
9393

94-
initClosed := false
95-
if f == l {
96-
initClosed = true
97-
}
94+
initClosed := f == l
9895

9996
for edge := 1; edge <= 8; edge <<= 1 {
10097
out = out[:0]
@@ -150,9 +147,11 @@ func ring(box orb.Bound, in orb.Ring) orb.Ring {
150147
}
151148

152149
// bitCode returns the point position relative to the bbox:
153-
// left mid right
154-
// top 1001 1000 1010
155-
// mid 0001 0000 0010
150+
//
151+
// left mid right
152+
// top 1001 1000 1010
153+
// mid 0001 0000 0010
154+
//
156155
// bottom 0101 0100 0110
157156
func bitCode(b orb.Bound, p orb.Point) int {
158157
code := 0

encoding/ewkb/ewkb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/binary"
66
"encoding/hex"
7-
"io/ioutil"
7+
"io"
88
"testing"
99

1010
"github.com/paulmach/orb"
@@ -37,7 +37,7 @@ func MustDecodeHex(s string) []byte {
3737

3838
func BenchmarkEncode_Point(b *testing.B) {
3939
g := orb.Point{1, 2}
40-
e := NewEncoder(ioutil.Discard)
40+
e := NewEncoder(io.Discard)
4141

4242
b.ReportAllocs()
4343
b.ResetTimer()
@@ -54,7 +54,7 @@ func BenchmarkEncode_LineString(b *testing.B) {
5454
{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5},
5555
{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5},
5656
}
57-
e := NewEncoder(ioutil.Discard)
57+
e := NewEncoder(io.Discard)
5858

5959
b.ReportAllocs()
6060
b.ResetTimer()

encoding/internal/wkbcommon/wkb.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,12 @@ func readByteOrderType(r io.Reader, buf []byte) (byteOrder, uint32, int, error)
284284
}
285285

286286
var order byteOrder
287-
if buf[0] == 0 {
287+
switch buf[0] {
288+
case 0:
288289
order = bigEndian
289-
} else if buf[0] == 1 {
290+
case 1:
290291
order = littleEndian
291-
} else {
292+
default:
292293
return 0, 0, 0, ErrNotWKB
293294
}
294295

encoding/mvt/marshal_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"math"
8+
"os"
99
"reflect"
1010
"testing"
1111

@@ -388,7 +388,7 @@ func comparePoints(t testing.TB, e, r []orb.Point, xEpsilon, yEpsilon float64) {
388388
}
389389

390390
func loadMVT(t testing.TB, tile maptile.Tile) []byte {
391-
data, err := ioutil.ReadFile(fmt.Sprintf("testdata/%d-%d-%d.mvt", tile.Z, tile.X, tile.Y))
391+
data, err := os.ReadFile(fmt.Sprintf("testdata/%d-%d-%d.mvt", tile.Z, tile.X, tile.Y))
392392
if err != nil {
393393
t.Fatalf("failed to load mvt file: %v", err)
394394
}
@@ -397,7 +397,7 @@ func loadMVT(t testing.TB, tile maptile.Tile) []byte {
397397
}
398398

399399
func loadGeoJSON(t testing.TB, tile maptile.Tile) map[string]*geojson.FeatureCollection {
400-
data, err := ioutil.ReadFile(fmt.Sprintf("testdata/%d-%d-%d.json", tile.Z, tile.X, tile.Y))
400+
data, err := os.ReadFile(fmt.Sprintf("testdata/%d-%d-%d.json", tile.Z, tile.X, tile.Y))
401401
if err != nil {
402402
t.Fatalf("failed to load mvt file: %v", err)
403403
}

encoding/mvt/unmarshal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"compress/gzip"
66
"errors"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99

1010
"github.com/paulmach/orb"
1111
"github.com/paulmach/orb/encoding/mvt/vectortile"
@@ -23,7 +23,7 @@ func UnmarshalGzipped(data []byte) (Layers, error) {
2323
return nil, fmt.Errorf("failed to create gzreader: %v", err)
2424
}
2525

26-
decoded, err := ioutil.ReadAll(gzreader)
26+
decoded, err := io.ReadAll(gzreader)
2727
if err != nil {
2828
return nil, fmt.Errorf("failed to unzip: %v", err)
2929
}

encoding/wkb/wkb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package wkb
33
import (
44
"bytes"
55
"encoding/binary"
6-
"io/ioutil"
6+
"io"
77
"testing"
88

99
"github.com/paulmach/orb"
@@ -27,7 +27,7 @@ func TestMustMarshal(t *testing.T) {
2727

2828
func BenchmarkEncode_Point(b *testing.B) {
2929
g := orb.Point{1, 2}
30-
e := NewEncoder(ioutil.Discard)
30+
e := NewEncoder(io.Discard)
3131

3232
b.ReportAllocs()
3333
b.ResetTimer()
@@ -44,7 +44,7 @@ func BenchmarkEncode_LineString(b *testing.B) {
4444
{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5},
4545
{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5},
4646
}
47-
e := NewEncoder(ioutil.Discard)
47+
e := NewEncoder(io.Discard)
4848

4949
b.ReportAllocs()
5050
b.ResetTimer()

encoding/wkt/benchmarks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package wkt
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
5+
"os"
66
"testing"
77

88
"github.com/paulmach/orb"
@@ -103,7 +103,7 @@ func BenchmarkUnmarshalMultiPolygon(b *testing.B) {
103103
}
104104

105105
func loadJSON(tb testing.TB, filename string, obj interface{}) {
106-
data, err := ioutil.ReadFile(filename)
106+
data, err := os.ReadFile(filename)
107107
if err != nil {
108108
tb.Fatalf("failed to load mvt file: %v", err)
109109
}

geo/area.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ func ringArea(r orb.Ring) float64 {
5656

5757
area := 0.0
5858
for i := 0; i < l; i++ {
59-
if i == l-3 { // i = N-3
59+
switch i {
60+
case l - 3: // i = N-3
6061
lo = l - 3
6162
mi = l - 2
6263
hi = 0
63-
} else if i == l-2 { // i = N-2
64+
case l - 2: // i = N-2
6465
lo = l - 2
6566
mi = 0
6667
hi = 0
67-
} else if i == l-1 { // i = N-1
68+
case l - 1: // i = N-1
6869
lo = 0
6970
mi = 0
7071
hi = 1
71-
} else { // i = 0 to N-3
72+
default: // i = 0 to N-3
7273
lo = i
7374
mi = i + 1
7475
hi = i + 2

geojson/feature_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package geojson
33
import (
44
"bytes"
55
"encoding/json"
6-
"io/ioutil"
6+
"os"
77
"reflect"
88
"strings"
99
"testing"
@@ -424,7 +424,7 @@ func TestFeature_MarshalBSON_extraMembers(t *testing.T) {
424424
// }
425425

426426
func BenchmarkFeatureMarshalJSON(b *testing.B) {
427-
data, err := ioutil.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
427+
data, err := os.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
428428
if err != nil {
429429
b.Fatalf("could not open file: %v", err)
430430
}
@@ -446,7 +446,7 @@ func BenchmarkFeatureMarshalJSON(b *testing.B) {
446446
}
447447

448448
func BenchmarkFeatureUnmarshalJSON(b *testing.B) {
449-
data, err := ioutil.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
449+
data, err := os.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
450450
if err != nil {
451451
b.Fatalf("could not open file: %v", err)
452452
}
@@ -463,7 +463,7 @@ func BenchmarkFeatureUnmarshalJSON(b *testing.B) {
463463
}
464464

465465
func BenchmarkFeatureMarshalBSON(b *testing.B) {
466-
data, err := ioutil.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
466+
data, err := os.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
467467
if err != nil {
468468
b.Fatalf("could not open file: %v", err)
469469
}
@@ -485,7 +485,7 @@ func BenchmarkFeatureMarshalBSON(b *testing.B) {
485485
}
486486

487487
func BenchmarkFeatureUnmarshalBSON(b *testing.B) {
488-
data, err := ioutil.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
488+
data, err := os.ReadFile("../encoding/mvt/testdata/16-17896-24449.json")
489489
if err != nil {
490490
b.Fatalf("could not open file: %v", err)
491491
}

0 commit comments

Comments
 (0)