Documentation
¶
Overview ¶
Package reflect provides reflection-based conversion utilities.
Index ¶
- func CopyProtoFields(src, dst protoreflect.Message) error
- func CreateDynamicMessage(md protoreflect.MessageDescriptor) *dynamicpb.Message
- func DurationPBToDuration(d *durationpb.Duration) time.Duration
- func DurationToDurationPB(d time.Duration) *durationpb.Duration
- func IsZeroValue(v reflect.Value) bool
- func JSONToStruct(data []byte, v any) error
- func ProtoToStruct(msg protoreflect.Message, target any) error
- func StructToJSON(v any) ([]byte, error)
- func StructToProto(src any, msg protoreflect.Message) error
- func TimeToTimestamp(t time.Time) *timestamppb.Timestamp
- func TimestampToTime(ts *timestamppb.Timestamp) time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyProtoFields ¶
func CopyProtoFields(src, dst protoreflect.Message) error
CopyProtoFields copies fields from one proto message to another.
func CreateDynamicMessage ¶
func CreateDynamicMessage(md protoreflect.MessageDescriptor) *dynamicpb.Message
CreateDynamicMessage creates a new dynamic protobuf message from a descriptor.
func DurationPBToDuration ¶
func DurationPBToDuration(d *durationpb.Duration) time.Duration
DurationPBToDuration converts google.protobuf.Duration to time.Duration
func DurationToDurationPB ¶
func DurationToDurationPB(d time.Duration) *durationpb.Duration
DurationToDurationPB converts time.Duration to google.protobuf.Duration
func IsZeroValue ¶
IsZeroValue checks if a reflect.Value is the zero value for its type.
func JSONToStruct ¶
JSONToStruct converts JSON bytes to a Go struct.
func ProtoToStruct ¶
func ProtoToStruct(msg protoreflect.Message, target any) error
ProtoToStruct converts a protobuf message to a Go struct using reflection.
func StructToJSON ¶
StructToJSON converts a Go struct to JSON bytes.
func StructToProto ¶
func StructToProto(src any, msg protoreflect.Message) error
StructToProto converts a Go struct to a protobuf message using reflection.
func TimeToTimestamp ¶
func TimeToTimestamp(t time.Time) *timestamppb.Timestamp
TimeToTimestamp converts time.Time to google.protobuf.Timestamp
func TimestampToTime ¶
func TimestampToTime(ts *timestamppb.Timestamp) time.Time
TimestampToTime converts google.protobuf.Timestamp to time.Time
Types ¶
This section is empty.