{"id":15651616,"url":"https://github.com/qdm12/reprint","last_synced_at":"2025-04-15T10:27:48.098Z","repository":{"id":65928075,"uuid":"222145945","full_name":"qdm12/reprint","owner":"qdm12","description":"Golang deep copying, THE RIGHT WAY :tm:","archived":false,"fork":false,"pushed_at":"2020-03-26T20:58:04.000Z","size":217,"stargazers_count":41,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:12:31.763Z","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":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qdm12.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":"2019-11-16T19:01:01.000Z","updated_at":"2025-03-07T15:52:49.000Z","dependencies_parsed_at":"2023-02-16T18:20:21.009Z","dependency_job_id":null,"html_url":"https://github.com/qdm12/reprint","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qdm12%2Freprint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qdm12%2Freprint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qdm12%2Freprint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qdm12%2Freprint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qdm12","download_url":"https://codeload.github.com/qdm12/reprint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249050910,"owners_count":21204715,"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-10-03T12:39:21.009Z","updated_at":"2025-04-15T10:27:48.062Z","avatar_url":"https://github.com/qdm12.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reprint\r\n\r\n*Reprint is a Go library to deep copy any object THE RIGHT WAY :tm:*\r\n\r\n[![reprint](https://github.com/qdm12/reprint/raw/master/title.png)](https://github.com/qdm12/reprint)\r\n\r\n[![Join Slack channel](https://img.shields.io/badge/slack-@qdm12-yellow.svg?logo=slack)](https://join.slack.com/t/qdm12/shared_invite/enQtOTE0NjcxNTM1ODc5LTYyZmVlOTM3MGI4ZWU0YmJkMjUxNmQ4ODQ2OTAwYzMxMTlhY2Q1MWQyOWUyNjc2ODliNjFjMDUxNWNmNzk5MDk)\r\n[![Build Status](https://travis-ci.org/qdm12/reprint.svg?branch=master)](https://travis-ci.org/qdm12/reprint)\r\n\r\n[![GitHub last commit](https://img.shields.io/github/last-commit/qdm12/reprint.svg)](https://github.com/qdm12/reprint/issues)\r\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/qdm12/reprint.svg)](https://github.com/qdm12/reprint/issues)\r\n[![GitHub issues](https://img.shields.io/github/issues/qdm12/reprint.svg)](https://github.com/qdm12/reprint/issues)\r\n\r\n## Features\r\n\r\nUnlike most libraries out there, this one deep copies by assigning new pointers to all data structures\r\nnested in a given object, hence doing it **THE RIGHT WAY :tm:**\r\n\r\nIt works with slices, arrays, maps, pointers, nested pointers, nils, structs (with unexported fields too), functions  and channels.\r\n\r\n*Limits*:\r\n\r\n- Functions pointers are not changed but that's by design\r\n- Channels buffered elements are not deep copied\r\n\r\n## Usage\r\n\r\n```sh\r\ngo get -u github.com/qdm12/reprint\r\n```\r\n\r\nYou can check out [Golang Playground](https://play.golang.org/p/ukbIYl_gLqu) and activate **Imports** at the top, or read this:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"fmt\"\r\n\r\n    \"github.com/qdm12/reprint\"\r\n)\r\n\r\nfunc main() {\r\n    one := 1\r\n    two := 2\r\n    type myType struct{ A *int }\r\n\r\n    // reprint.FromTo usage:\r\n    var x, y myType\r\n    x.A = \u0026one\r\n    reprint.FromTo(\u0026x, \u0026y) // you can check the error returned also\r\n    y.A = \u0026two\r\n    fmt.Println(x.A, *x.A) // 0xc0000a0010 1\r\n    fmt.Println(y.A, *y.A) // 0xc0000a0018 2\r\n\r\n    // reprint.This usage:\r\n    x2 := myType{\u0026one}\r\n    out := reprint.This(x2)\r\n    y2 := out.(myType)\r\n    y2.A = \u0026two\r\n    fmt.Println(x2.A, *x2.A) // 0xc0000a0010 1\r\n    fmt.Println(y2.A, *y2.A) // 0xc0000a0018 2\r\n}\r\n```\r\n\r\n## Development\r\n\r\n1. Install [Docker](https://docs.docker.com/install/)\r\n    - On Windows, share a drive with Docker Desktop and have the project on that partition\r\n    - On OSX, share your project directory with Docker Desktop\r\n1. With [Visual Studio Code](https://code.visualstudio.com/download), install the [remote containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)\r\n1. In Visual Studio Code, press on `F1` and select `Remote-Containers: Open Folder in Container...`\r\n1. Your dev environment is ready to go!... and it's running in a container :+1:\r\n\r\n## TODOs\r\n\r\n- (Research) deep copy elements currently in channel\r\n    - Race conditions\r\n    - Pause channel?\r\n- Polish `FromTo`\r\n    - Initialize copy to copy's type if it's a typed nil\r\n    - Initialize copy to original's type if it's an untyped nil\r\n    - Returns typed nil instead of untyped nil if original is a nil pointer (typed)\r\n- `forceCopyValue` might not be needed\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdm12%2Freprint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqdm12%2Freprint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqdm12%2Freprint/lists"}