{"id":22450634,"url":"https://github.com/xieyuschen/deepcopy","last_synced_at":"2025-03-27T12:18:49.627Z","repository":{"id":185217463,"uuid":"673169143","full_name":"xieyuschen/deepcopy","owner":"xieyuschen","description":"Go Deep Copy Library with Fully Testing","archived":false,"fork":false,"pushed_at":"2023-08-15T03:30:39.000Z","size":73,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-01T16:48:25.502Z","etag":null,"topics":["deepcopy","go","golang","golang-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mohae/deepcopy","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xieyuschen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-01T03:07:26.000Z","updated_at":"2024-11-05T02:30:35.000Z","dependencies_parsed_at":"2024-10-23T11:17:32.598Z","dependency_job_id":null,"html_url":"https://github.com/xieyuschen/deepcopy","commit_stats":null,"previous_names":["xieyuschen/deepcopy"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuschen%2Fdeepcopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuschen%2Fdeepcopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuschen%2Fdeepcopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xieyuschen%2Fdeepcopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xieyuschen","download_url":"https://codeload.github.com/xieyuschen/deepcopy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841761,"owners_count":20681195,"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":["deepcopy","go","golang","golang-library"],"created_at":"2024-12-06T05:16:56.500Z","updated_at":"2025-03-27T12:18:49.608Z","avatar_url":"https://github.com/xieyuschen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeepCopy\n\n![example workflow](https://github.com/xieyuschen/deepcopy/actions/workflows/go.yml/badge.svg)\n[![codecov](https://codecov.io/gh/xieyuschen/deepcopy/branch/master/graph/badge.svg?token=E1IU1FAK92)](https://codecov.io/gh/xieyuschen/deepcopy)\n\nIt's fully tested and has 100% test coverage, feel free to use it!\n\nThe repo is original at [mohae/deepcopy](https://github.com/mohae/deepcopy). As it hasn't been maintained for a long time, it's maintained here with bug fix and new features.\n\n## Expected Behaviors in DeepCopy Library\n\nThis topic lists some expected behaviors in `DeepCopy` library here. Deep copy circular references will return error instead of fatal stack overflow.\n\n| Type             | Expected Behavior                                                                                                                                                                                                                                                                                                                                            |\n| :--------------- |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Primitive Types  | Copy by the value                                                                                                                                                                                                                                                                                                                                            |\n| Struct           | Construct a new struct, deep copy each field according to the respective behaviors                                                                                                                                                                                                                                                                           |\n| Slice/Array      | Construct a new slice/array, deep copy underlying types according to the respective behaviors                                                                                                                                                                                                                                                                |\n| Interface        | Construct a new interface, deep copy underlying types according to the respective behaviors                                                                                                                                                                                                                                                                  |\n| Map              | Construct a new map, deep copy underlying types according to the respective behaviors                                                                                                                                                                                                                                                                        |\n| Channel          | Channel will be shared between source and copied.                                                                                                                                                                                                                                                                                                            |\n| Function         | Function will be shared betwwen source and copied. Beware of the variables captured by your function when you do deep copy                                                                                                                                                                                                                                   |\n| Pointer          | Construct a new object with the type under the pointer according to the respective behaviors and then return the a pointer to the new object                                                                                                                                                                                                                 |\n| time.Time        | A new time.Time object will be constructed with the shared `*time.Location` pointer inside it                                                                                                                                                                                                                                                                |\n| Unexposed Fields | Unexposed fields are not supported in reflect, as a result, it cannot copy the inside status. \u003cbr/\u003eAccroding to this, states of objects cannot be conserved and some of objects cannot be used at all. \u003cbr/\u003eFor example, a mutex will be deep copied like a value because all internal states are lost during deep copy. A `*os.File` cannot be used at all. |\n\n## Acknowledge\n\nThere was a [deep copy proposal](https://github.com/golang/go/issues/51520) in Go but got declined due to no consensus.\nThe brief of arguments are listed below.\n\n- The deep copy should be a library, instead of go language itself.  \n  \"ianlancetaylor:_... the best way forward here is going to be to write the version of the function that you think we need. And that implementation can live anywhere...\"_\n\n- The behaviors of deep copy for circular/recursive data structure.\n- The behaviors of deep copy for stateful structures such as `*os.File`, `mutex`, `channel` and so on.\n- ...\n\nAs the deep copy function shouldn't belong to go language, and it's useful in some cases, the library came into being.\n\n## Contribute\n\nThis repo will be maintained in the long term even though the original author start to maintain the original repo. I will\ntry to fix any unexpected bug and add some features if necessary. Glad to receive issues and PRs.\n\nThank [Joel Scoble](https://github.com/mohae), [Mathieu Champlon](https://github.com/mat007), [Damien Neil](https://github.com/neild), [Sergey Cherepanov](https://github.com/cheggaaa) for their previous work.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuschen%2Fdeepcopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxieyuschen%2Fdeepcopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxieyuschen%2Fdeepcopy/lists"}