Documentation ¶
Overview ¶
Package protoyaml contains a YAML decoder in the spirit of what https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson is for JSON.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Unmarshal ¶
func Unmarshal(bs []byte, m protoreflect.ProtoMessage) error
Unmarshal interprets the bytes as YAML and populates m.
Example ¶
var got testproto.Message if err := Unmarshal([]byte(`astring: hello`), &got); err != nil { return nil, err } return &got, nil
Output:
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder can be used to decode one or more YAML documents as Protobuf messages. It is not goroutine-safe, but is goroutine-compatible.
func NewDecoder ¶
NewDecoder creats a new decoder reading from the given stream of YAML text.
func (*Decoder) Decode ¶
Decode decodes the next document as a message. The argument can either be a proto.Message, or a protoreflect.Message. Returns io.EOF if there are no more documents.
func (*Decoder) MessageTypeResolver ¶
func (d *Decoder) MessageTypeResolver(r protoregistry.MessageTypeResolver)
MessageTypeResolver sets a custom resolver for anypb.Any types. The default in NewDecoder is protoregistry.GlobalTypes.