Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToBase64Converter ¶
func BytesToBase64Converter() []copier.TypeConverter
BytesToBase64Converter creates and returns a slice of custom type converters for the `copier` library. These converters handle the automatic conversion of byte slices ([]byte or []uint8) to their Base64-encoded string representation during a copy operation.
Returns: A slice of `copier.TypeConverter` structs.
func Copy ¶
Copy performs a **deep copy** of fields from the 'source' object to the 'target' object. It uses the 'copier' library with specific options for deep copying and custom conversions.
target: A pointer to the destination (struct, map, etc.) where data will be copied into. source: The source object (struct, map, slice, etc.) to copy data from. Returns: An error if the copy operation fails.
func JSON ¶
JSON is a helper function that performs a deep copy of a 'source' object into a new instance of type 'T', then sends the result as a JSON response using the Echo web framework. T: The desired type of the final JSON output struct. status: The HTTP status code to be returned (e.g., 200, 201). source: The initial data object to be copied from (e.g., a database model). err: An existing error that should immediately trigger a return if non-nil.
func MustCopy ¶
MustCopy is a generic helper that performs a **deep copy** into a **newly created** instance of the specified type 'T', ignoring any potential errors.
T: The value type of the destination object to be created and returned. source: The object to copy data from. Returns: A new instance of type 'T' containing the copied data. NOTE: Use with caution, as ignoring the error means a failed copy will result in an uninitialized or partially-initialized object.
Types ¶
type TypeConverters ¶
type TypeConverters []copier.TypeConverter
TypeConverters is a custom type definition, essentially a slice of 'copier.TypeConverter' functions. Each TypeConverter function defines how to copy data between two fields of different types (e.g., converting a string field to a time.Time field).
var Converters TypeConverters
Converters is the package-level variable that holds all registered custom type converters. This variable is typically used by the Copy and MustCopy functions in this package.
func (*TypeConverters) Add ¶
func (t *TypeConverters) Add(converters ...copier.TypeConverter)
Add is a method on the TypeConverters type used to register one or more custom conversion functions to the collection.
converters: A variadic argument of one or more 'copier.TypeConverter' functions.