protobuf

package
v1.21.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2022 License: OSL-3.0 Imports: 6 Imported by: 0

README

Protobuf

I think I found a fix for ambiguous data. From my testing, problems only happen with protowire.BytesType, as the result can be a string, bytes or message. You can solve some cases by seeing if the data will parse as a message, or by checking if the data is binary [1]. However if the data can parse as a message, the result could be multiple types.

To solve this, I wrote a package that has separate types for message, string and bytes. If I encounter ambiguous data, I add two entries. One as a string (or bytes) and one as a message. I give both the same field number, and use my new types as the discriminator.

  1. https://github.com/golang/go/blob/go1.17.6/src/net/http/sniff.go#L297-L309

Documentation

Overview

Protocol Buffers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message map[Tag]interface{}

func Decode

func Decode(src io.Reader) (Message, error)

func Unmarshal

func Unmarshal(buf []byte) (Message, error)

func (Message) Add added in v1.17.8

func (m Message) Add(num protowire.Number, name string, val Message) error

func (Message) Get

func (m Message) Get(num protowire.Number, name string) Message

func (Message) GetBytes

func (m Message) GetBytes(num protowire.Number, name string) []byte

func (Message) GetFixed64 added in v1.20.5

func (m Message) GetFixed64(num protowire.Number, name string) uint64

func (Message) GetMessages

func (m Message) GetMessages(num protowire.Number, name string) []Message

func (Message) GetString

func (m Message) GetString(num protowire.Number, name string) string

func (Message) GetVarint added in v1.20.2

func (m Message) GetVarint(num protowire.Number, name string) uint64

func (Message) GoString

func (m Message) GoString() string

func (Message) Marshal

func (m Message) Marshal() []byte

type Tag

type Tag struct {
	protowire.Number
	Name string
}

func (Tag) MarshalText

func (t Tag) MarshalText() ([]byte, error)

encoding/json

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL