Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToStructpb ¶
ToStructpb converts a protobuf oneof value into a JSON-compatible *structpb.Struct, or returns an error if the conversion is impossible. It also returns a string representation of the underlying type.
Example: type TestProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` Data isTestProto_Data `protobuf_oneof:"data"` } msg := &testapi.TestRequest{ Test: &testapi.TestProto{ Uuid: "uuid", Data: &testapi.TestProto_Assignable100{Assignable100: &testapi.Assignable100{Data100: "test100"}}, }, } protostruct, typeName, err := oneofproto.ToStructpb(msg.Test.Data) where protostruct is a *structpb.Struct JSON compatible with &testapi.Assignable100{Data100: "test100"} and typeName is "*testapi.Assignable100"
func ToStructpbDefer ¶
ToStructpbDefer mirrors the functionality of ToStructpb but uses a panic-recovery mechanism instead of kind checking.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.