{"id":15393869,"url":"https://github.com/mitchellh/patchstructure","last_synced_at":"2025-04-15T23:52:29.444Z","repository":{"id":66228469,"uuid":"80948918","full_name":"mitchellh/patchstructure","owner":"mitchellh","description":"Go library for representing and applying patches to modify existing Go structures","archived":false,"fork":false,"pushed_at":"2017-02-04T23:23:52.000Z","size":28,"stargazers_count":55,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T05:59:26.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchellh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-02-04T21:13:14.000Z","updated_at":"2025-03-04T10:36:13.000Z","dependencies_parsed_at":"2023-04-22T03:39:24.619Z","dependency_job_id":null,"html_url":"https://github.com/mitchellh/patchstructure","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"255f8906de990bbf6b865fc56eb2a4604528c2d0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fpatchstructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fpatchstructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fpatchstructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fpatchstructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchellh","download_url":"https://codeload.github.com/mitchellh/patchstructure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173061,"owners_count":21224481,"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":[],"created_at":"2024-10-01T15:20:37.684Z","updated_at":"2025-04-15T23:52:29.438Z","avatar_url":"https://github.com/mitchellh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# patchstructure [![GoDoc](https://godoc.org/github.com/mitchellh/patchstructure?status.svg)](https://godoc.org/github.com/mitchellh/patchstructure)\n\npatchstructure is a Go library for applying patches to modify existing\nGo structures.\n\npatchstructure is based on\n[JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902), but\napplies to Go strucutures instead of JSON objects.\n\nThe goal of patchstructure is to provide a single API and format for\nrepresenting and applying changes to Go structures. With this in place,\ndiffs between structures can be represented, changes to a structure\ncan be treated as a log, etc.\n\n## Features\n\n  * Apply a \"patch\" to perform a set of operations on a Go structure\n\n  * Operations support add, remove, replace, move, copy\n\n  * Operations work on all Go primitive types and collection types\n\n  * JSON encode/decode Operation structures\n\nFor an exhaustive list of supported features, please view the\n[JSON Patch RFC (RFC 6902)](https://tools.ietf.org/html/rfc6902) which\nthis implements completely, but for Go structures. Exceptions to the RFC\nare documented below.\n\n## Differences from RFC 6902\n\nRFC 6902 was created for JSON structures. Due to minor differences in\nGo structures, there are some differences. These don't change the\nfunction of the RFC, but are important to know when using this library:\n\n  * The \"copy\" operation will perform a deep copy by default using\n    [copystructure](https://github.com/mitchellh/copystructure). You can\n    set the `Shallow` field to true on the operation to avoid this behavior.\n\n  * The \"test\" operation is currently implemented with `reflect.DeepEqual`\n    which is _not_ exactly correct according to the RFC. This will work fine\n    for most basic primitives but the limitations of that approach should be\n    known. In the future we should rework this.\n\n## Installation\n\nStandard `go get`:\n\n```\n$ go get github.com/mitchellh/patchstructure\n```\n\n## Usage \u0026 Example\n\nFor usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/patchstructure).\n\nA quick code example is shown below:\n\n```go\ncomplex := map[string]interface{}{\n\t\"alice\": 42,\n\t\"bob\": []interface{}{\n\t\tmap[string]interface{}{\n\t\t\t\"name\": \"Bob\",\n\t\t},\n\t},\n}\n\nvalue, err := Patch(complex, []*Operation{\n\t\u0026Operation{\n\t\tOp:   OpCopy,\n\t\tPath: \"/alice\",\n\t\tFrom: \"/bob\",\n\t},\n\n\t\u0026Operation{\n\t\tOp:    OpReplace,\n\t\tPath:  \"/alice/0/name\",\n\t\tValue: \"Alice\",\n\t},\n})\nif err != nil {\n\tpanic(err)\n}\n\nfmt.Printf(\"%s\", value)\n// Output:\n// map[alice:[map[name:Alice]] bob:[map[name:Bob]]]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fpatchstructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellh%2Fpatchstructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fpatchstructure/lists"}