Copier is a Go library that deep copies data between structs, maps, and slices using reflection-based field mapping and struct tag controls. At its core, it automatically transfers values by matching source and destination fields by name, type, and methods, creating fully independent copies of nested data structures to prevent shared references and unintended mutations.
The library distinguishes itself through tag-driven copy rules that give developers fine-grained control over the copying process. Struct tags can enforce mandatory field copying, exclude specific fields from transfer, or map fields with different names between source and destination types. It also supports automatic type coercion between compatible slice and map types, and can skip zero-value fields in the source to prevent overwriting existing destination data with empty values.
Beyond basic struct-to-struct copying, Copier handles copying between slices and maps with the same mapping rules, and can convert a single struct into a slice element. The library provides method-to-field resolution, allowing source methods to populate destination fields, and supports recursive deep copying of arbitrarily nested structures. Documentation and installation are available through the project's repository.