{"id":13414113,"url":"https://github.com/gotidy/copy","last_synced_at":"2025-12-25T18:53:38.300Z","repository":{"id":56091571,"uuid":"302559434","full_name":"gotidy/copy","owner":"gotidy","description":"Package for fast copying structs of different types","archived":false,"fork":false,"pushed_at":"2020-12-28T08:02:43.000Z","size":216,"stargazers_count":47,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:53:32.307Z","etag":null,"topics":["copy","deepcopy","go","golang","golang-library","golang-package","performance"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotidy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-09T06:59:08.000Z","updated_at":"2024-06-18T04:04:51.000Z","dependencies_parsed_at":"2022-08-15T13:00:43.544Z","dependency_job_id":null,"html_url":"https://github.com/gotidy/copy","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotidy%2Fcopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotidy%2Fcopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotidy%2Fcopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotidy%2Fcopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotidy","download_url":"https://codeload.github.com/gotidy/copy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221504088,"owners_count":16833954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copy","deepcopy","go","golang","golang-library","golang-package","performance"],"created_at":"2024-07-30T20:01:58.032Z","updated_at":"2025-12-25T18:53:38.269Z","avatar_url":"https://github.com/gotidy.png","language":"Go","readme":"# Package for fast copying structs of different types\n\n[![GoDev](https://img.shields.io/static/v1?label=godev\u0026message=reference\u0026color=00add8)][godev] [![Go Report Card](https://goreportcard.com/badge/github.com/gotidy/copy)][goreport] [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n[godev]: https://pkg.go.dev/github.com/gotidy/copy\n[goreport]: https://goreportcard.com/report/github.com/gotidy/copy\n\nThis package is meant to make copying of structs to/from others structs a bit easier.\n\nNested structures, embedded types, pointers, sql null types are supported.\n\n## Installation\n\n```sh\ngo get -u github.com/gotidy/copy\n```\n\n## Example\n\n```go\ntype Person struct {\n    Name       string\n    MiddleName *string\n    Surname    string\n}\n\ntype User struct {\n    Person\n    Email   string\n    Age     int8\n    Married bool\n}\n\ntype Employee struct {\n    Name       string\n    MiddleName string\n    Surname    string\n    Email      string\n    Age        int\n}\n\nsrc := User{\n    Person: Person{\n        Name:       \"John\",\n        MiddleName: nil,\n        Surname:    \"Smith\",\n    },\n    Email:   \"john.smith@joy.me\",\n    Age:     33,\n    Married: false,\n}\ndst := Employee{}\n\ncopiers := copy.New() // New(\"json\")\ncopiers.Copy(\u0026dst, \u0026src)\n\n// Or more fast use case is to create the type specific copier.\n\ncopier := copiers.Get(\u0026Employee{}, \u0026User{}) // Created once for a pair of types.\ncopier.Copy(\u0026dst, \u0026src)\n\n```\n\n## Alternative projects\n\n- [ulule/Deepcopier](https://github.com/ulule/deepcopier)\n- [jinzhu/Copier](https://github.com/jinzhu/copier)\n\n### [Benchmark](https://github.com/gotidy/copy-bench)\n\nBenchmarks source code can be found [here](https://github.com/gotidy/copy-bench)\n\n```sh\ngo test -bench=. -benchmem ./...\ngoos: darwin\ngoarch: amd64\npkg: github.com/gotidy/copy-bench\nBenchmarkManualCopy-12         177310519         6.92 ns/op          0 B/op        0 allocs/op\nBenchmarkCopiers-12             13476417         84.1 ns/op          0 B/op        0 allocs/op\nBenchmarkCopier-12              40226689         27.5 ns/op          0 B/op        0 allocs/op\nBenchmarkJinzhuCopier-12          407480         2711 ns/op       2480 B/op       34 allocs/op\nBenchmarkDeepcopier-12            262836         4346 ns/op       4032 B/op       73 allocs/op\nPASS\nok      github.com/gotidy/copy-bench    6.922s\n```\n\nSee the [documentation][godev] for more information.\n\n## License\n\n[Apache 2.0](https://github.com/gotidy/copy/blob/master/LICENSE)\n","funding_links":[],"categories":["Utilities","Reflection","公用事业公司","Utility","工具库`可以提升效率的通用代码库和工具`","工具库"],"sub_categories":["Utility/Miscellaneous","HTTP Clients","实用程序/Miscellaneous","查询语","Fail injection","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotidy%2Fcopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotidy%2Fcopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotidy%2Fcopy/lists"}