Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OverrideDefaultFields ¶
func OverrideDefaultFields(fields ...string)
func SliceStructTimeToPbTimestamp ¶
func SliceStructTimeToPbTimestamp(pbObjSlice any, fromObjSlice any, processFields *[]string, diveFields ...string) error
SliceStructTimeToPbTimestamp converts all time.Time fields specified in processFields from a slice of structs (fromObjSlice) to *timestamppb.Timestamp fields in the corresponding protobuf object slice (pbObjSlice).
pbObjSlice and fromObjSlice must be pointers to slices of the same length. processFields is a pointer to a slice of field names to process; if nil or empty, defaultFields is used. diveFields specifies the field names to recursively process (for nested structs or slices).
Example usage:
err := SliceStructTimeToPbTimestamp(&pbParkSlice, &parkSlice, nil, "Landmarks", "Event")
This will convert pbParkSlice[i].Landmarks[j].CreatedAt, pbParkSlice[i].Landmarks[j].UpdatedAt, pbParkSlice[i].Event.DeletedAt, etc.
func StructTimeToPbTimestamp ¶
func StructTimeToPbTimestamp(pbObj any, fromObj any, processFields *[]string, diveFields ...string) error
StructTimeToPbTimestamp converts all time.Time fields specified in processFields from a struct (fromObj) to *timestamppb.Timestamp fields in the corresponding protobuf object (pbObj).
pbObj and fromObj must be pointers to structs with matching fields. processFields is a pointer to a slice of field names to process; if nil or empty, defaultFields is used. diveFields specifies the field names to recursively process (for nested structs or slices).
Example usage:
err := StructTimeToPbTimestamp(&pbPark, &park, nil, "Landmarks", "Event")
This will convert pbPark.Landmarks[i].CreatedAt, pbPark.Landmarks[i].UpdatedAt, pbPark.Event.DeletedAt, etc.
Types ¶
This section is empty.