A Go code generator that creates type-to-type and field-to-field copy functions without reflection, offering high performance and customization.
Copygen is a Go code generator that creates custom functions to copy values between Go types and map fields between structs. It solves the problem of writing repetitive, error-prone manual copy code by generating efficient, reflection-free implementations that are up to 391x faster than reflection-based alternatives like jinzhu/copier.
Go developers working with multiple model layers (e.g., domain models, database models, API models) who need performant, maintainable data transformation between types without runtime overhead.
Developers choose Copygen for its combination of high performance (no reflection, no allocations), full Go type support, and extensive customization via templates and matching options, allowing it to generate not just copy functions but any type-based code.
Copygen generates code based on Go types. Generate type-based code to copy values from type to type and fields from struct to struct by default (copier without reflection).
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates reflection-free, allocation-free code that benchmarks 391x faster than reflection-based alternatives like jinzhu/copier, as stated in the README.
Handles all Go types including slices, maps, channels, and interfaces, enabling complex data mapping without limitations.
Offers automatching, manual mapping via map/tag, depth control, and template-driven generation for tailored code beyond basic copying.
Allows custom .go or .tmpl templates to generate any type-based code, such as repositories or API wrappers, as shown in examples.
Requires configuring both a YML file and a GO interface file with specific options, which adds overhead compared to simpler, single-file solutions.
Programmatic use or modifications to the source code trigger AGPL compliance requirements, and a license exception is needed for unrestricted use, as admitted in the README.
Deep copy functionality is listed as roadmap and not fully implemented, forcing users to rely on custom converters or templates for nested structures.