Skip to content

Commit f9fed71

Browse files
committed
fix lint errors: remove ioutil references and other fixes
1 parent b3aa927 commit f9fed71

File tree

15 files changed

+49
-46
lines changed

15 files changed

+49
-46
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ var c = jsoniter.Config{
120120
MarshalFloatWith6Digits: true,
121121
}.Froze()
122122

123-
osmm.CustomJSONMarshaler = c
123+
osm.CustomJSONMarshaler = c
124124
osm.CustomJSONUnmarshaler = c
125125
```
126126

annotate/geo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func wayCentroid(w *osm.Way) orb.Point {
5252
return point
5353
}
5454

55-
// orientation will annotate the the orientation of multipolygon relation members.
55+
// orientation will annotate the orientation of multipolygon relation members.
5656
// This makes it possible to reconstruct relations with partial data in the right direction.
5757
// Return value indicates if the result is 'tainted', e.g. not all way members were present.
5858
func orientation(members osm.Members, ways map[osm.WayID]*osm.Way, at time.Time) bool {

annotate/way_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/xml"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"reflect"
109
"testing"
@@ -132,7 +131,7 @@ func BenchmarkWays(b *testing.B) {
132131
}
133132

134133
func loadTestdata(tb testing.TB, filename string) *osm.OSM {
135-
data, err := ioutil.ReadFile(filename)
134+
data, err := os.ReadFile(filename)
136135
if err != nil {
137136
tb.Fatalf("unable to open file: %v", err)
138137
}

change_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"encoding/xml"
8-
"io/ioutil"
8+
"os"
99
"testing"
1010
)
1111

@@ -237,11 +237,13 @@ func TestChange_HistoryDatasource(t *testing.T) {
237237
}
238238

239239
func BenchmarkChange_MarshalXML(b *testing.B) {
240-
filename := "testdata/changeset_38162206.osc"
241-
data := readFile(b, filename)
240+
data, err := os.ReadFile("testdata/changeset_38162206.osc")
241+
if err != nil {
242+
b.Fatalf("unable to read file: %v", err)
243+
}
242244

243245
c := &Change{}
244-
err := xml.Unmarshal(data, c)
246+
err = xml.Unmarshal(data, c)
245247
if err != nil {
246248
b.Fatalf("unable to unmarshal: %v", err)
247249
}
@@ -270,7 +272,7 @@ func BenchmarkChange_MarshalXML(b *testing.B) {
270272
// }
271273

272274
func BenchmarkChange_MarshalJSON(b *testing.B) {
273-
data, err := ioutil.ReadFile("testdata/minute_871.osc")
275+
data, err := os.ReadFile("testdata/minute_871.osc")
274276
if err != nil {
275277
b.Fatalf("could not read file: %v", err)
276278
}
@@ -292,7 +294,7 @@ func BenchmarkChange_MarshalJSON(b *testing.B) {
292294
}
293295

294296
func BenchmarkChange_UnmarshalJSON(b *testing.B) {
295-
data, err := ioutil.ReadFile("testdata/minute_871.osc")
297+
data, err := os.ReadFile("testdata/minute_871.osc")
296298
if err != nil {
297299
b.Fatalf("could not read file: %v", err)
298300
}
@@ -320,8 +322,10 @@ func BenchmarkChange_UnmarshalJSON(b *testing.B) {
320322
}
321323

322324
func BenchmarkChangeset_UnmarshalXML(b *testing.B) {
323-
filename := "testdata/changeset_38162206.osc"
324-
data := readFile(b, filename)
325+
data, err := os.ReadFile("testdata/changeset_38162206.osc")
326+
if err != nil {
327+
b.Fatalf("unable to read file: %v", err)
328+
}
325329

326330
b.ReportAllocs()
327331
b.ResetTimer()

diff_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package osm
22

33
import (
44
"encoding/xml"
5+
"os"
56
"reflect"
67
"testing"
78
)
@@ -72,10 +73,13 @@ func TestDiff_MarshalXML(t *testing.T) {
7273
}
7374

7475
func TestDiff(t *testing.T) {
75-
data := readFile(t, "testdata/annotated_diff.xml")
76+
data, err := os.ReadFile("testdata/annotated_diff.xml")
77+
if err != nil {
78+
t.Fatalf("unable to read file: %v", err)
79+
}
7680

7781
diff := &Diff{}
78-
err := xml.Unmarshal(data, &diff)
82+
err = xml.Unmarshal(data, &diff)
7983
if err != nil {
8084
t.Errorf("unable to unmarshal: %v", err)
8185
}
@@ -137,10 +141,13 @@ func TestDiff(t *testing.T) {
137141
}
138142

139143
func BenchmarkDiff_Marshal(b *testing.B) {
140-
data := readFile(b, "testdata/annotated_diff.xml")
144+
data, err := os.ReadFile("testdata/annotated_diff.xml")
145+
if err != nil {
146+
b.Fatalf("unable to read file: %v", err)
147+
}
141148

142149
diff := &Diff{}
143-
err := xml.Unmarshal(data, &diff)
150+
err = xml.Unmarshal(data, &diff)
144151
if err != nil {
145152
b.Fatalf("unmarshal error: %v", err)
146153
}
@@ -156,7 +163,10 @@ func BenchmarkDiff_Marshal(b *testing.B) {
156163
}
157164

158165
func BenchmarkDiff_Unmarshal(b *testing.B) {
159-
data := readFile(b, "testdata/annotated_diff.xml")
166+
data, err := os.ReadFile("testdata/annotated_diff.xml")
167+
if err != nil {
168+
b.Fatalf("unable to read file: %v", err)
169+
}
160170

161171
b.ReportAllocs()
162172
b.ResetTimer()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/paulmach/osm
22

3-
go 1.13
3+
go 1.16
44

55
require (
66
github.com/datadog/czlib v0.0.0-20160811164712-4bc9a24e37f2

osm_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"encoding/xml"
7-
"io"
8-
"os"
97
"reflect"
108
"testing"
119
)
@@ -301,18 +299,3 @@ func TestOSM_MarshalXML(t *testing.T) {
301299
t.Errorf("incorrect marshal, got: %s", string(data))
302300
}
303301
}
304-
305-
func readFile(t testing.TB, filename string) []byte {
306-
f, err := os.Open(filename)
307-
if err != nil {
308-
t.Fatalf("unable to open %s: %v", filename, err)
309-
}
310-
defer f.Close()
311-
312-
data, err := io.ReadAll(f)
313-
if err != nil {
314-
t.Fatalf("unable to read file %s: %v", filename, err)
315-
}
316-
317-
return data
318-
}

osmgeojson/benchmarks_test.go

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

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

88
"github.com/paulmach/osm"
@@ -88,7 +88,7 @@ func BenchmarkConvert_NoIDsMetaMembership(b *testing.B) {
8888
}
8989

9090
func parseFile(t testing.TB, filename string) *osm.OSM {
91-
data, err := ioutil.ReadFile(filename)
91+
data, err := os.ReadFile(filename)
9292
if err != nil {
9393
t.Fatalf("could not read file: %v", err)
9494
}

osmgeojson/build_polygon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (ctx *context) buildPolygon(relation *osm.Relation) *geojson.Feature {
6161
}
6262

6363
if len(ls) == 0 {
64-
// we have the way but none the the node members
64+
// we have the way but none of the node members
6565
continue
6666
}
6767

osmgeojson/convert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ type rawFC struct {
674674
func jsonLoop(t *testing.T, fc *geojson.FeatureCollection) *rawFC {
675675
data, err := json.Marshal(fc)
676676
if err != nil {
677-
t.Fatalf("unabled to marshal fc: %v", err)
677+
t.Fatalf("unable to marshal fc: %v", err)
678678
}
679679

680680
result := &rawFC{}

0 commit comments

Comments
 (0)