finds.dev← search

// the find

jinzhu/copier

★ 6,178 · Go · MIT · updated Mar 2026

Copier for golang, copy value from struct to struct and more

Copier is a Go struct-to-struct copy library from the GORM author. It handles field matching by name, method-to-field copying, slices, maps, and type coercion with a small tag system. Useful when you're mapping between domain and DTO types and don't want to write forty assignment lines by hand.

Method-to-field copying (source method return value → destination field with same name) is a genuinely useful trick that most similar libs skip. The tag system covers the real edge cases: required fields that should error instead of silently zero out (`must,nopanic`), fields that should be forcibly overwritten even under IgnoreEmpty (`override`), and exclusions (`-`). DeepCopy option prevents the classic shared-pointer footgun where two structs end up pointing at the same nested slice. Actively maintained by jinzhu, same person behind GORM, so it won't be abandoned next week.

Reflection at runtime — every copy call walks struct fields via reflect, which shows up in tight loops; the benchmark file exists but there's no stated performance target or guidance on when to reach for code generation instead. Custom field name mapping via tags works, but bidirectional or complex transformations (rename + type convert) require you to implement a converter function and register it separately, which the README barely documents. No compile-time safety: a renamed field in one struct silently stops copying to the other with no error unless you remembered to add `must`. The single `copier.go` file at 800+ lines with no internal package structure makes contributing or auditing the edge cases harder than it needs to be.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →