pbutil

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromValue

func FromValue(val *structpb.Value) (any, error)

func ToListValue

func ToListValue(v []interface{}, t *runtimev1.Type) (*structpb.ListValue, error)

ToListValue converts a map to a google.protobuf.List. It's similar to structpb.NewList(), but it recurses on valToPB instead of structpb.NewList to add support for more types. Providing t as a type hint is optional.

func ToStruct

func ToStruct(v map[string]any, t *runtimev1.StructType) (*structpb.Struct, error)

ToStruct converts a map to a google.protobuf.Struct. It's similar to structpb.NewStruct(), but it recurses on valToPB instead of structpb.NewValue to add support for more types. Providing t as a type hint is optional.

func ToStructCoerceKeys

func ToStructCoerceKeys(v map[any]any, t *runtimev1.MapType) (*structpb.Struct, error)

ToStructCoerceKeys converts a map with non-string keys to a google.protobuf.Struct. It attempts to coerce the keys to JSON strings. Providing t as a type hint is optional.

func ToValue

func ToValue(v any, t *runtimev1.Type) (*structpb.Value, error)

ToValue converts any value to a google.protobuf.Value. It's similar to structpb.NewValue, but adds support for a few extra primitive types.

func WriteHash added in v0.32.0

func WriteHash(v *structpb.Value, w io.Writer) error

WriteHash writes the contents of a structpb.Value to a writer in a deterministic order. The output is not structured and can't be parsed back, so it's mainly suitable for writing to a hash writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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