# jinzhu/copier

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jinzhu-copier).**

6,172 stars · 495 forks · Go · MIT

## Links

- GitHub: https://github.com/jinzhu/copier
- awesome-repositories: https://awesome-repositories.com/repository/jinzhu-copier.md

## Topics

`copy` `go` `golang` `golang-package`

## Description

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.

## Tags

### Data & Databases

- [Struct-to-Struct Copiers](https://awesome-repositories.com/f/data-databases/naming-conventions/struct-field-mappings/struct-to-struct-copiers.md) — Copies values between structs by matching fields, methods, and tags for automatic data transfer. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Go Struct Copiers](https://awesome-repositories.com/f/data-databases/naming-conventions/struct-field-mappings/go-struct-copiers.md) — Deep copies values between Go structs, maps, and slices using field matching and struct tags.
- [Reflection-Based Field Matchers](https://awesome-repositories.com/f/data-databases/naming-conventions/struct-field-mappings/reflection-based-field-matchers.md) — Matches struct fields by name, type, and tags using Go reflection for automatic value transfer.
- [Method-to-Field Resolvers](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/field-to-model-mappers/method-to-field-resolvers.md) — Provides method-to-field resolution for populating destination fields from source method return values.
- [Zero-Value Field Skipping](https://awesome-repositories.com/f/data-databases/custom-data-fields/field-format-overrides/empty-field-serialization-overrides/zero-value-field-skipping.md) — Skips zero-value source fields during copy to avoid overwriting existing destination data with empty values. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Enforced Field Copiers](https://awesome-repositories.com/f/data-databases/field-validation/automatic-field-population/enforced-field-copiers.md) — Enforces mandatory field copying with error or panic if the field is not populated. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Map-to-Map Copiers](https://awesome-repositories.com/f/data-databases/key-value-stores/structured-object-mappings/object-linked-key-value-mappings/map-value-transformers/map-key-value-transformers/map-to-map-copiers.md) — Copies key-value pairs between maps with automatic type conversion for compatible types. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))

### Programming Languages & Runtimes

- [Deep Copying Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/object-cloning-techniques/deep-copying-libraries.md) — Provides a deep copying library for creating independent duplicates of nested data structures.
- [Slice and Map Copiers](https://awesome-repositories.com/f/programming-languages-runtimes/go-data-mapping-libraries/slice-and-map-management-patterns/slice-and-map-copiers.md) — Copies values between slices or maps with automatic type conversion for compatible types.
- [Slice and Map Type Converters](https://awesome-repositories.com/f/programming-languages-runtimes/go-data-mapping-libraries/slice-and-map-management-patterns/slice-and-map-type-converters.md) — Converts between compatible slice and map types automatically during copy operations.

### Development Tools & Productivity

- [Copy Rule Controllers](https://awesome-repositories.com/f/development-tools-productivity/clipboard-management/clipboard-copying/flash-driven-copying/copy-rule-controllers.md) — Controls copy behavior with struct tags to enforce, ignore, or rename fields during value transfer.

### Software Engineering & Architecture

- [Field Copy Exclusions](https://awesome-repositories.com/f/software-engineering-architecture/field-tagging/field-copy-exclusions.md) — Provides struct tags to skip copying specific fields, preventing unwanted data transfer between structs. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Copy Behavior Controllers](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags/copy-behavior-controllers.md) — Uses struct tags to enforce, ignore, or rename fields during value transfer between types.
- [Copy Control Tags](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags/copy-control-tags.md) — Uses struct tags to enforce, exclude, or rename fields during copy operations for fine-grained data transfer control. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Struct-to-Struct Field Matchers](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags/reflection-based-map-mapping/struct-to-struct-field-matchers.md) — Implements reflection-based field matching between source and destination structs for automatic copying.
- [Struct Tag Mapping Utilities](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags/struct-tag-mapping-utilities.md) — Controls copy behavior with struct tags to enforce, ignore, or rename fields during value transfer.
- [Deep Copy Utilities](https://awesome-repositories.com/f/software-engineering-architecture/performance-reliability/performance-optimization/data-handling-throughput/zero-copy-mechanisms/deep-copy-utilities.md) — Creates fully independent copies of complex nested data structures to prevent shared references. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))
- [Zero-Value Field Skippers](https://awesome-repositories.com/f/software-engineering-architecture/in-place-array-manipulations/value-removal-algorithms/zero-value-trimming/zero-value-field-skippers.md) — Filters out zero-value source fields to avoid overwriting destination data with empty values.
- [Type Coercion Utilities](https://awesome-repositories.com/f/software-engineering-architecture/type-coercion-utilities.md) — Automatically converts between compatible slice and map types during copy operations.

### Web Development

- [Reflection-Based Data Mappers](https://awesome-repositories.com/f/web-development/reflection-based-data-binding/reflection-based-data-mappers.md) — Transfers data between Go types by matching fields, methods, and tags at runtime.

### Operating Systems & Systems Programming

- [Slice-to-Slice Copiers](https://awesome-repositories.com/f/operating-systems-systems-programming/memory-slicing-mechanisms/copy-operations/slice-copy-functions/slice-to-slice-copiers.md) — Copies values between slices using the same field mapping rules as struct-to-struct copying. ([source](https://cdn.jsdelivr.net/gh/jinzhu/copier@master/README.md))

### Part of an Awesome List

- [Development Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/development-utilities.md) — Copies values between structs.
