{"id":20872386,"url":"https://github.com/romnn/go-recursive-sort","last_synced_at":"2025-05-12T13:33:40.041Z","repository":{"id":57562451,"uuid":"324598259","full_name":"romnn/go-recursive-sort","owner":"romnn","description":"recursively sort any golang interface for comparisons in your unit tests.","archived":false,"fork":false,"pushed_at":"2022-11-01T21:30:11.000Z","size":28,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T16:02:48.329Z","etag":null,"topics":["golang","interfaces-go","json","recursive","reflection","sort","sorting","testing","unittest"],"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/romnn.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":"2020-12-26T16:56:58.000Z","updated_at":"2024-03-20T02:35:29.000Z","dependencies_parsed_at":"2022-09-16T19:51:23.810Z","dependency_job_id":null,"html_url":"https://github.com/romnn/go-recursive-sort","commit_stats":null,"previous_names":["romnnn/go-recursive-sort"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romnn%2Fgo-recursive-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romnn%2Fgo-recursive-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romnn%2Fgo-recursive-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romnn%2Fgo-recursive-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romnn","download_url":"https://codeload.github.com/romnn/go-recursive-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253748289,"owners_count":21957900,"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":["golang","interfaces-go","json","recursive","reflection","sort","sorting","testing","unittest"],"created_at":"2024-11-18T06:18:57.910Z","updated_at":"2025-05-12T13:33:39.700Z","avatar_url":"https://github.com/romnn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-recursive-sort\n\n[![Build Status](https://github.com/romnn/go-recursive-sort/workflows/test/badge.svg)](https://github.com/romnn/go-recursive-sort/actions)\n[![GitHub](https://img.shields.io/github/license/romnn/go-recursive-sort)](https://github.com/romnn/go-recursive-sort)\n[![GoDoc](https://godoc.org/github.com/romnn/go-recursive-sort?status.svg)](https://godoc.org/github.com/romnn/go-recursive-sort)\n[![Test Coverage](https://codecov.io/gh/romnn/go-recursive-sort/branch/master/graph/badge.svg)](https://codecov.io/gh/romnn/go-recursive-sort)\n\nRecursively sort any golang `interface{}` for comparisons in your unit tests.\n\n#### Installation\n\n```bash\n$ go get github.com/romnn/go-recursive-sort\n```\n\n#### Example (JSON)\n\n```go\n// examples/json/json.go\n\npackage main\n\nimport (\n\t\"log\"\n\n\trecursivesort \"github.com/romnn/go-recursive-sort\"\n)\n\nfunc main() {\n\ta := `{\"test\": [\"a\", \"c\", \"b\"]}`\n\tb := `{\"test\": [\"c\", \"a\", \"b\"]}`\n\tequal, err := recursivesort.EqualJSON(a, b)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to compare JSON values: %v\", err)\n\t}\n\tif !equal {\n\t\tlog.Fatalf(\"expected %s == %s\", a, b)\n\t}\n}\n\n```\n\n#### Example (Struct)\n\n```go\n// examples/struct/struct.go\n\npackage main\n\nimport (\n\t\"log\"\n\t\"reflect\"\n\n\trecursivesort \"github.com/romnn/go-recursive-sort\"\n)\n\n// Common fields must be exported to be sorted\ntype Common struct {\n\tValues          map[string][]string\n\twillNotBeSorted []string\n}\n\n// Struct fields must be exported to be sorted\ntype Struct struct {\n\tA      string\n\tB      string\n\tC      []string\n\tCommon Common\n}\n\nfunc main() {\n\ta := Struct{\n\t\tA: \"a\",\n\t\tB: \"b\",\n\t\tC: []string{\"a\", \"b\", \"c\"},\n\t\tCommon: Common{\n\t\t\tValues: map[string][]string{\n\t\t\t\t\"a\": []string{\"a\", \"b\", \"c\"},\n\t\t\t\t\"b\": []string{\"a\", \"b\", \"c\"},\n\t\t\t},\n\t\t\twillNotBeSorted: []string{\"a\", \"b\"},\n\t\t},\n\t}\n\n\tb := Struct{\n\t\tA: \"a\",\n\t\tB: \"b\",\n\t\tC: []string{\"c\", \"b\", \"a\"},\n\t\tCommon: Common{\n\t\t\tValues: map[string][]string{\n\t\t\t\t\"b\": []string{\"c\", \"b\", \"a\"},\n\t\t\t\t\"a\": []string{\"c\", \"b\", \"a\"},\n\t\t\t},\n\t\t\twillNotBeSorted: []string{\"a\", \"b\"},\n\t\t},\n\t}\n\n\tsort := recursivesort.RecursiveSort{}\n\tsort.Sort(\u0026a)\n\tsort.Sort(\u0026b)\n\n\tif equal := reflect.DeepEqual(a, b); !equal {\n\t\tlog.Fatalf(\"expected %v == %v\", a, b)\n\t}\n}\n\n```\n\nFor more examples, see `examples/`.\n\n#### Development\n\n###### Prerequisites\n\nBefore you get started, make sure you have installed the following tools\n\n```bash\n$ python3 -m pip install pre-commit bump2version invoke\n$ go install golang.org/x/tools/cmd/goimports@latest\n$ go install golang.org/x/lint/golint@latest\n$ go install github.com/fzipp/gocyclo/cmd/gocyclo@latest\n```\n\nPlease always make sure all code checks pass:\n\n```bash\ninvoke pre-commit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromnn%2Fgo-recursive-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromnn%2Fgo-recursive-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromnn%2Fgo-recursive-sort/lists"}