A Go package for deep copying structs with field mapping, skipping, and context passing.
Deepcopier is a Go package that provides utilities for deep copying data between structs with flexible field mapping and transformation options. It solves the problem of manually copying data between different struct types, such as when converting database models to API response objects or between different layers of an application.
Go developers working with data transformation between structs, particularly those building web APIs, ORM layers, or applications with complex data models that need conversion between different representations.
Developers choose Deepcopier because it provides a clean, declarative way to handle struct copying with features like field mapping, context passing, and SQL null handling that aren't available in standard Go assignment or simple reflection-based copying libraries.
simple struct copying for golang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows copying between structs with different field names using the 'field' struct tag, as shown in the README example mapping 'DisplayName' from 'Name'.
Supports passing context maps to methods during copying via the 'context' tag, enabling dynamic logic like in the 'MethodThatTakesContext' example.
Provides special handling for sql.Null* types with a 'force' option to copy values directly, simplifying database-to-application conversions.
Copies values from both fields and methods, offering flexibility in data derivation, as demonstrated with method-based copying in the examples.
Uses Go's reflection package, which can be slower than manual copying and may impact performance in latency-sensitive or high-throughput scenarios.
Lacks built-in hooks for pre-copy or post-copy operations, complex nested struct transformations, or error handling during the copy process.
Relies on string-based struct tags for configuration, which are error-prone and offer less compiler safety compared to code-based approaches.