jonas-p / go-shp

Go library for reading and writing ESRI Shapefiles. Pure Golang implementation based on the ESRI Shapefile technical description.
MIT License
258 stars 68 forks source link

Off by one error in *reader.Read #42

Open reubent opened 4 years ago

reubent commented 4 years ago

In the example in README.md, there is the code

// loop through all features in the shapefile
for shape.Next() {

but in (r *Reader) Next() you return false if the file hits EOF, meaning the last item in the file will not be read.

        r.shape.read(er)
    if er.e != nil {
        r.err = fmt.Errorf("Error while reading next shape: %v", er.e)
        return false
    }

image

I know some behaviour changed around EOF as error between go versions a while back (there was very briefly a similar issue in grpc) so I presume this has snuck in that way.