Documentation ¶
Index ¶
- func FromValue(val *structpb.Value) (any, error)
- func ToListValue(v []interface{}, t *runtimev1.Type) (*structpb.ListValue, error)
- func ToListValueUnknown(s any, t *runtimev1.Type) (*structpb.ListValue, error)
- func ToSliceAny[T any](v []T) []any
- func ToSliceString(a any) []string
- func ToStruct(v map[string]any, t *runtimev1.StructType) (*structpb.Struct, error)
- func ToStructCoerceKeys(v map[any]any, t *runtimev1.MapType) (*structpb.Struct, error)
- func ToStructCoerceKeysUnknown(s any, t *runtimev1.MapType) (*structpb.Struct, error)
- func ToValue(v any, t *runtimev1.Type) (*structpb.Value, error)
- func WriteHash(v *structpb.Value, w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToListValue ¶
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 ToListValueUnknown ¶ added in v0.41.0
ToListValueUnknown converts a list google.protobuf.List similar to ToListValue but when the type of list is list of unknown type. It uses reflection so should not be used when ToListValue can be used.
func ToSliceAny ¶ added in v0.43.0
ToSliceAny converts a slice of any type to a slice of type any (interface{}) making the slice compatible with structpb.NewStruct
func ToSliceString ¶ added in v0.43.0
ToSliceString (as opposed to ToSliceAny) converts a slice of any type to a slice of strings It returns nil if the input is nil or not a slice of any
func ToStruct ¶
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 ¶
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 ToStructCoerceKeysUnknown ¶ added in v0.41.0
ToStructCoerceKeysUnknown is similar to ToStructCoerceKeys but when type of map is unknown. It uses reflection so should not be used when ToStructCoerceKeys can be used.
Types ¶
This section is empty.