Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

packed repeated fields #21

@ghost

Description

https://protobuf.dev/programming-guides/encoding#packed

using this file:

package main

import (
   "google.golang.org/protobuf/testing/protopack"
   "os"
)

func main() {
   inBytes := protopack.Message{
      protopack.Tag{3, protopack.BytesType}, protopack.LengthPrefix{
         protopack.Float32(1.1),
         protopack.Float32(2.2),
         protopack.Float32(3.3),
      },
   }.Marshal()
   os.WriteFile("packed.bin", inBytes, 0666)
}

https://google.golang.org/protobuf/testing/protopack#Message.Marshal

if I try to scan:

package main

import (
   "github.com/protocolbuffers/protoscope"
   "os"
)

func main() {
   inBytes, err := os.ReadFile("packed.bin")
   if err != nil {
      panic(err)
   }
   scanner := protoscope.NewScanner(string(inBytes))
   if _, err := scanner.Exec(); err != nil {
      panic(err)
   }
}

I get this result:

panic: unrecognized symbol "\x1a\f\xcď?\xcd\xcc\f@33S@"

the tool works:

> protoscope packed.bin
3: {`cdcc8c3fcdcc0c4033335340`}

but neither the module or tool seem to have an option for dealing with this. I check WriterOptions but didn't see anything:

https://pkg.go.dev/github.com/protocolbuffers/protoscope#WriterOptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions