diff --git a/cmd/pbf/info/info.go b/cmd/pbf/info/info.go index 8c14e0b..d84ff22 100644 --- a/cmd/pbf/info/info.go +++ b/cmd/pbf/info/info.go @@ -158,7 +158,7 @@ func runInfo(in io.Reader, ncpu uint16, extended bool) *extendedHeader { func renderJSON(info *extendedHeader, extended bool) { // marshall the smallest struct needed - var v interface{} + var v any if extended { v = info } else { diff --git a/decoder.go b/decoder.go index 15b8325..2f3201b 100644 --- a/decoder.go +++ b/decoder.go @@ -59,12 +59,12 @@ type encoded struct { } type decoded struct { - elements []interface{} + elements []any err error } type pair struct { - element interface{} + element any err error } @@ -184,7 +184,7 @@ func NewDecoder(ctx context.Context, reader io.Reader, opts ...DecoderOption) (* // or Relation struct representing the underlying OpenStreetMap PBF data, or // error encountered. The end of the input stream is reported by an io.EOF // error. -func (d *Decoder) Decode() (interface{}, error) { +func (d *Decoder) Decode() (any, error) { decoded, more := <-d.pairs if !more { return nil, io.EOF @@ -321,7 +321,7 @@ func coalesce(cfg decoderOptions, outputs ...chan decoded) (pairs chan pair) { // elements unmarshals an array of OSM elements from an array of protobuf encoded // bytes. The bytes could possibly be compressed; zlibBuf is used to facilitate // decompression. -func elements(header *protobuf.BlobHeader, blob *protobuf.Blob, zlibBuf *bytes.Buffer) ([]interface{}, error) { +func elements(header *protobuf.BlobHeader, blob *protobuf.Blob, zlibBuf *bytes.Buffer) ([]any, error) { var buf []byte switch { @@ -368,7 +368,7 @@ func elements(header *protobuf.BlobHeader, blob *protobuf.Blob, zlibBuf *bytes.B return nil, err } - return []interface{}{h}, nil + return []any{h}, nil } case "OSMData": return parsePrimitiveBlock(buf) diff --git a/decoder_elements.go b/decoder_elements.go index 5fd8030..94fa0ef 100644 --- a/decoder_elements.go +++ b/decoder_elements.go @@ -21,7 +21,7 @@ import ( "m4o.io/pbf/protobuf" ) -func parsePrimitiveBlock(buffer []byte) ([]interface{}, error) { +func parsePrimitiveBlock(buffer []byte) ([]any, error) { pb := &protobuf.PrimitiveBlock{} if err := proto.Unmarshal(buffer, pb); err != nil { return nil, err @@ -29,7 +29,7 @@ func parsePrimitiveBlock(buffer []byte) ([]interface{}, error) { c := newBlockContext(pb) - elements := make([]interface{}, 0) + elements := make([]any, 0) for _, pg := range pb.GetPrimitivegroup() { elements = append(elements, c.decodeNodes(pg.GetNodes())...) elements = append(elements, c.decodeDenseNodes(pg.GetDense())...) @@ -40,8 +40,8 @@ func parsePrimitiveBlock(buffer []byte) ([]interface{}, error) { return elements, nil } -func (c *blockContext) decodeNodes(nodes []*protobuf.Node) (elements []interface{}) { - elements = make([]interface{}, len(nodes)) +func (c *blockContext) decodeNodes(nodes []*protobuf.Node) (elements []any) { + elements = make([]any, len(nodes)) for i, node := range nodes { elements[i] = &Node{ @@ -56,9 +56,9 @@ func (c *blockContext) decodeNodes(nodes []*protobuf.Node) (elements []interface return elements } -func (c *blockContext) decodeDenseNodes(nodes *protobuf.DenseNodes) []interface{} { +func (c *blockContext) decodeDenseNodes(nodes *protobuf.DenseNodes) []any { ids := nodes.GetId() - elements := make([]interface{}, len(ids)) + elements := make([]any, len(ids)) tic := c.newTagsContext(nodes.GetKeysVals()) dic := c.newDenseInfoContext(nodes.GetDenseinfo()) @@ -83,8 +83,8 @@ func (c *blockContext) decodeDenseNodes(nodes *protobuf.DenseNodes) []interface{ return elements } -func (c *blockContext) decodeWays(nodes []*protobuf.Way) []interface{} { - elements := make([]interface{}, len(nodes)) +func (c *blockContext) decodeWays(nodes []*protobuf.Way) []any { + elements := make([]any, len(nodes)) for i, node := range nodes { refs := node.GetRefs() @@ -108,8 +108,8 @@ func (c *blockContext) decodeWays(nodes []*protobuf.Way) []interface{} { return elements } -func (c *blockContext) decodeRelations(nodes []*protobuf.Relation) []interface{} { - elements := make([]interface{}, len(nodes)) +func (c *blockContext) decodeRelations(nodes []*protobuf.Relation) []any { + elements := make([]any, len(nodes)) for i, node := range nodes { elements[i] = &Relation{