{"id":19666576,"url":"https://github.com/xaionaro-go/object","last_synced_at":"2025-02-27T04:17:25.159Z","repository":{"id":259313066,"uuid":"876828613","full_name":"xaionaro-go/object","owner":"xaionaro-go","description":"Yet a one more deep-copy\u0026traverse package for Go, but this time with capability of custom processing (like removing secrets from your data)","archived":false,"fork":false,"pushed_at":"2024-10-26T21:24:51.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T08:40:15.193Z","etag":null,"topics":["censor","clean","copy","deep-copy","deepcopy","privacy","remove-secrets"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xaionaro-go.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":"2024-10-22T16:11:39.000Z","updated_at":"2024-10-26T21:24:55.000Z","dependencies_parsed_at":"2024-10-24T09:47:47.896Z","dependency_job_id":"969c6c4d-ec19-49fc-9f3a-11821033e4cc","html_url":"https://github.com/xaionaro-go/object","commit_stats":null,"previous_names":["xaionaro-go/object","xaionaro-go/deepcopy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fobject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fobject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fobject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fobject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xaionaro-go","download_url":"https://codeload.github.com/xaionaro-go/object/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240976185,"owners_count":19887439,"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":["censor","clean","copy","deep-copy","deepcopy","privacy","remove-secrets"],"created_at":"2024-11-11T16:28:09.178Z","updated_at":"2025-02-27T04:17:25.139Z","avatar_url":"https://github.com/xaionaro-go.png","language":"Go","readme":"# About\n[![Go Reference](https://godoc.org/github.com/xaionaro-go/object?status.svg)](https://godoc.org/github.com/xaionaro-go/object)\n[![Go Report Card](https://goreportcard.com/badge/github.com/xaionaro-go/object?branch=main)](https://goreportcard.com/report/github.com/xaionaro-go/object)\n\nThis package provides functions for deep copying an arbitrary object in Go. The difference of this deepcopier from others is that this allows to use a custom function that modifies the copied data. Personally I use it to erase all the secrets from my data while doing a copy (that in turn is used for logging).\n\n# How to use\n\n### JUST DEEP COPY\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/xaionaro-go/object\"\n)\n\ntype myStruct struct {\n\tPublicData string\n\tSecretData string `secret:\"\"`\n}\n\nfunc main() {\n\tvalue := myStruct{\n\t\tPublicData: \"true == true\",\n\t\tSecretData: \"but there is a nuance\",\n\t}\n\n\tcensoredValue := object.DeepCopy(value)\n\tfmt.Println(censoredValue)\n}\n\n```\n```sh\n$ go run ./examples/object/\n{true == true but there is a nuance}\n```\n\n\n### REMOVE MY SECRETS\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/xaionaro-go/object\"\n)\n\ntype myStruct struct {\n\tPublicData string\n\tSecretData string `secret:\"\"`\n}\n\nfunc main() {\n\tvalue := myStruct{\n\t\tPublicData: \"true == true\",\n\t\tSecretData: \"but there is a nuance\",\n\t}\n\n\tcensoredValue := object.DeepCopyWithoutSecrets(value)\n\tfmt.Println(censoredValue)\n}\n```\n```sh\n$ go run ./examples/censoredvalue/\n{true == true }\n```\n\n### CUSTOM PROCESSING\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\n\t\"github.com/xaionaro-go/object\"\n)\n\ntype myStruct struct {\n\tPublicData string\n\tSecretData string `secret:\"\"`\n}\n\nfunc main() {\n\tvalue := myStruct{\n\t\tPublicData: \"true == true\",\n\t\tSecretData: \"but there is a nuance\",\n\t}\n\n\tcensoredValue := object.DeepCopy(value, object.OptionWithVisitorFunc(func(_ *object.ProcContext, v reflect.Value, sf *reflect.StructField) (reflect.Value, bool, error) {\n\t\tif sf == nil {\n\t\t\treturn v, true, nil\n\t\t}\n\t\tswitch sf.Name {\n\t\tcase \"PublicData\":\n\t\t\treturn reflect.ValueOf(\"true == false\"), true, nil\n\t\tcase \"SecretData\":\n\t\t\treturn reflect.ValueOf(\"this is the nuance, sometimes\"), true, nil\n\t\t}\n\t\treturn v, true, nil\n\t}))\n\tfmt.Println(censoredValue)\n}\n```\n```sh\n$ go run ./examples/customprocessing/\n{true == false this is the nuance, sometimes}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaionaro-go%2Fobject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxaionaro-go%2Fobject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaionaro-go%2Fobject/lists"}