protobuf

package
v0.0.0-...-a1fe31f Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package protobuf provides helpers for working with golang/protobuf types.

Package protobuf provides helpers for working with golang/protobuf types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyMessageTypeOf

func AnyMessageTypeOf(msg proto.Message) string

AnyMessageTypeOf returns the any.Any type of msg.

func AsMessages

func AsMessages(messages interface{}) []proto.Message

AsMessages casts the given slice of values (that implement the proto.Message interface) to a slice of proto.Message. If the length of the slice is 0, it returns nil.

func Bool

func Bool(val bool) *wrappers.BoolValue

Bool converts a bool to a pointer to a wrappers.BoolValue.

func Duration

func Duration(d time.Duration) *duration.Duration

Duration converts a time.Duration to a pointer to a duration.Duration.

func ExpectEqual

func ExpectEqual(t *testing.T, want, got interface{}) bool

ExpectEqual will test that want == got for protobufs, call t.Error if it does not, and return a bool to indicate the result. This mimics the behavior of the testify `assert` functions.

func MustMarshalAny

func MustMarshalAny(pb proto.Message) *any.Any

MustMarshalAny marshals a protobuf into an any.Any type, panicking if that operation fails.

func MustMarshalJSON

func MustMarshalJSON(msg proto.Message) string

MustMarshalJSON marshals msg to indented JSON.

func RequireEqual

func RequireEqual(t *testing.T, want, got interface{})

RequireEqual will test that want == got for protobufs, call t.fatal if it does not, This mimics the behavior of the testify `require` functions.

func UInt32

func UInt32(val uint32) *wrappers.UInt32Value

UInt32 converts a uint32 to a pointer to a wrappers.UInt32Value.

func UInt32OrDefault

func UInt32OrDefault(val uint32, def uint32) *wrappers.UInt32Value

UInt32OrDefault returns a wrapped UInt32Value. If val is 0, def is wrapped and returned.

func UInt32OrNil

func UInt32OrNil(val uint32) *wrappers.UInt32Value

UInt32OrNil returns a wrapped UInt32Value. If val is 0, nil is returned

Types

This section is empty.

Jump to

Keyboard shortcuts

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