{"id":15923962,"url":"https://github.com/protolambda/messagediff","last_synced_at":"2025-08-15T19:32:58.406Z","repository":{"id":57492250,"uuid":"191026691","full_name":"protolambda/messagediff","owner":"protolambda","description":"A library for computing diffs of arbitrary Golang structs | Hard-fork of d4l3k/messagediff with new options/features","archived":false,"fork":false,"pushed_at":"2020-09-22T22:39:13.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-29T01:40:45.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/protolambda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-06-09T15:59:58.000Z","updated_at":"2024-07-14T18:10:18.000Z","dependencies_parsed_at":"2022-09-01T21:02:42.999Z","dependency_job_id":null,"html_url":"https://github.com/protolambda/messagediff","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protolambda%2Fmessagediff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protolambda%2Fmessagediff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protolambda%2Fmessagediff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protolambda%2Fmessagediff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protolambda","download_url":"https://codeload.github.com/protolambda/messagediff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229948945,"owners_count":18149571,"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-06T21:03:15.672Z","updated_at":"2024-12-16T10:43:10.810Z","avatar_url":"https://github.com/protolambda.png","language":"Go","readme":"# messagediff\n\nA library for doing diffs of arbitrary Golang structs. Fork of [d4l3k/messagediff](https://github.com/d4l3k/messagediff).\nGo-moduled, more options.\n\nIf the unsafe package is available messagediff will diff unexported fields in\naddition to exported fields. This is primarily used for testing purposes as it\nallows for providing informative error messages.\n\nOptions:\n\n- fields in structs can be tagged as `testdiff:\"ignore\"` to make messagediff skip it when doing the comparison (see example).\n- fields can also be ignored by passing an option: `PrettyDiff(a, b, IgnoreStructField(\"X\"), ...)`\n- ignore the differences in empty slices and nil slices. `PrettyDiff(a, b, SliceWeakEmptyOption{}, ...)`\n\n\n## Example Usage\n\n```go\npackage main\n\nimport \"github.com/protolambda/messagediff\"\n\ntype someStruct struct {\n    A, b int\n    C []int\n}\n\nfunc main() {\n    a := someStruct{1, 2, []int{1}}\n    b := someStruct{1, 3, []int{1, 2}}\n    diff, equal := messagediff.PrettyDiff(a, b)\n    /*\n        diff =\n        `added: .C[1] = 2\n        modified: .b, from = 2; to = 3`\n\n        equal = false\n    */\n}\n\n```\n\n### Test usage example\n\n```go\nimport \"github.com/protolambda/messagediff\"\n\n...\n\ntype someStruct struct {\n    A, b int\n    C []int\n}\n\nfunc TestSomething(t *testing.T) {\n    want := someStruct{1, 2, []int{1}}\n    got := someStruct{1, 3, []int{1, 2}}\n    if diff, equal := messagediff.PrettyDiff(want, got); !equal {\n        t.Errorf(\"Unexpected difference in something: %s\", got, diff)\n    }\n}\n```\n\n### Ignore struct field with tag\n\nTo ignore a field in a struct, just annotate it with testdiff:\"ignore\" like\nthis:\n```go\npackage main\n\nimport \"github.com/protolambda/messagediff\"\n\ntype someStruct struct {\n    A int\n    B int `testdiff:\"ignore\"`\n}\n\nfunc main() {\n    a := someStruct{1, 2}\n    b := someStruct{1, 3}\n    diff, equal := messagediff.PrettyDiff(a, b)\n    /*\n        equal = true\n        diff = \"\"\n    */\n}\n```\n\nSee the `DeepDiff` function for using the diff results programmatically.\n\n## License\n\nOriginal: Copyright (c) 2015 [Tristan Rice](https://fn.lc) \u003crice@fn.lc\u003e,\n GitHub: [d4l3k/messagediff](https://github.com/d4l3k/messagediff)\n\nmessagediff is licensed under the MIT license. See the LICENSE file for more information.\n\nbypass.go and bypasssafe.go are borrowed from\n[go-spew](https://github.com/davecgh/go-spew) and have a seperate copyright\nnotice.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotolambda%2Fmessagediff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotolambda%2Fmessagediff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotolambda%2Fmessagediff/lists"}