pb

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufToProto

func BufToProto(r io.Reader, msg proto.Message) error

BufToProto, unmarshal buffer to proto message instance.

func BytesToProto

func BytesToProto(b []byte, msg proto.Message) error

func BytesToStruct

func BytesToStruct(b []byte) (*structpb.Struct, error)

func Contains added in v0.30.4

func Contains[T proto.Message](collection []T, message T) bool

Contains returns true if the collection contains the message.

func JSONToStruct

func JSONToStruct(val map[string]interface{}) (*structpb.Struct, error)

JSONconverts a map decoded from JSON to a protobuf struct. The reason that the map can't be directly converted to a struct using structpb.NewStruct is that when gqlgen decodes a JSON object it calls decoder.UseNumber() on the json.Decoder. As a result, numeric values are decoded as json.Number, instead of float, and structpb.NewStruct doesn't know how to handle that.

func NewStruct

func NewStruct() *structpb.Struct

NewStruct, returns *structpb.Struct instance with initialized Fields map.

func ProtoToBuf

func ProtoToBuf(w io.Writer, msg proto.Message) error

ProtoToBuf, marshal proto message to buffer.

func ProtoToBytes

func ProtoToBytes(msg proto.Message) ([]byte, error)

ProtoToBuf, marshal proto message to buffer.

func ProtoToStr

func ProtoToStr(msg proto.Message) string

ProtoToStr, marshal proto message to string representation.

func UnmarshalNext

func UnmarshalNext(d *json.Decoder, m proto.Message) error

UnmarshalNext, JSON decoder helper function to unmarshal next message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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