{"id":19850502,"url":"https://github.com/mroth/orderedmap","last_synced_at":"2026-06-16T09:31:10.170Z","repository":{"id":183814219,"uuid":"670763262","full_name":"mroth/orderedmap","owner":"mroth","description":"🐜 ordered map implementation for Go","archived":false,"fork":false,"pushed_at":"2025-01-07T22:38:29.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-17T19:48:39.409Z","etag":null,"topics":["data-structures","go","go-module","golang"],"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/mroth.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":"2023-07-25T19:27:42.000Z","updated_at":"2025-07-07T15:53:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"31f1128a-60a8-4054-b527-212fe400f916","html_url":"https://github.com/mroth/orderedmap","commit_stats":null,"previous_names":["mroth/orderedmap"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mroth/orderedmap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mroth%2Forderedmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mroth%2Forderedmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mroth%2Forderedmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mroth%2Forderedmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mroth","download_url":"https://codeload.github.com/mroth/orderedmap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mroth%2Forderedmap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34400451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-structures","go","go-module","golang"],"created_at":"2024-11-12T13:26:22.970Z","updated_at":"2026-06-16T09:31:10.144Z","avatar_url":"https://github.com/mroth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# orderedmap :ant:\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/mroth/orderedmap.svg)](https://pkg.go.dev/github.com/mroth/orderedmap)\n\nOptimal, constant time implementation of ordered maps for Go with a simple API.\n\nSupports handy new style iteration via the range function in go1.23 and greater.\n\n\n## Usage\n\n### Basic operations\n\nCreating an ordered map uses any generic type `K comparable, V any`:\n```go\n// equivalent of: make(map[string]int)\nm := orderedmap.New[string, int]()\n```\n\nYou can specify an initial capacity hint:\n```go\n// equivalent of: make(map[string]int, 1000)\nm := orderedmap.WithCapacity[string, int](1000)\n```\n\nSetting a value:\n```go\n// equivalent of m[\"foo\"] = 1\nm.Set(\"foo\", 1)\n```\n\nRetrieving a value is equally simple, and uses the same `bool` ok secondary\nreturn pattern to indicate whether a value was found in the map:\n```go\n// equivalent of val, ok := m[\"foo\"]\nval, ok := m.Get(\"foo\")\n```\n\n## Iteration :sparkles:\n\nOn go1.23, you can simply range across the `All()` function, which will yield\nkey value pairs based on their insertion order:\n```go\nfor k, v := range m.All() {\n    fmt.Printf(\"k = %v, v = %v\\n\", k, v)\n}\n```\n\nSee also `Backward()` to iterate from newest to oldest instead, as well as\n included `Keys()` and `Values()` iterators.\n\n\n### Support\n\nTo use this module with new iterator range syntax, you'll need to use go1.23 or\ngreater.  The functionality is hidden behind build constraints so you can use\nthis module today with any version of Go that supports generics (\u003e=go1.18),\nalbeit without the handy range iterator support!\n\n\n## Comparison with other Go modules\n\nUpon my review, [wk8/go-ordered-map](https://github.com/wk8/go-ordered-map)\nappeared to be the best existing library, offering constant time operations and\nreasonable memory footprint. This module took some design cues from it. That\nsaid, there are some intentional design differences -- comparing this module\nwith it, we optimize for:\n\n* :bug: Simpler API (less exposed surface area, similar to standard library maps).\n* :seedling: Reduced feature set (no built-in YAML serialization, for example).\n* :sparkles: Use new range expressions for easy iteration on go1.23 and greater.\n* :zap: Equally performant.\n* :zero: Zero dependencies.\n\n### Other alternatives\nAs per other options, the README from `wk8/go-ordered-map` offers a summary:\n\n* [iancoleman/orderedmap](https://github.com/iancoleman/orderedmap) only accepts\n  `string` keys, its `Delete` operations are linear.\n* [cevaris/ordered_map](https://github.com/cevaris/ordered_map) uses a channel\n  for iterations, and leaks goroutines if the iteration is interrupted before\n  fully traversing the map.\n* [mantyr/iterator](https://github.com/mantyr/iterator) also uses a channel for\n  iterations, and its `Delete` operations are linear.\n* [samdolan/go-ordered-map](https://github.com/samdolan/go-ordered-map) adds\n  unnecessary locking (users should add their own locking instead if they need\n  it), its `Delete` and `Get` operations are linear, iterations trigger a linear\n  memory allocation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmroth%2Forderedmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmroth%2Forderedmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmroth%2Forderedmap/lists"}