{"id":38345052,"url":"https://github.com/secnot/orderedmap","last_synced_at":"2026-01-17T03:02:34.954Z","repository":{"id":57498571,"uuid":"94617915","full_name":"secnot/orderedmap","owner":"secnot","description":"OrderedMap is a Go implentation of a map that preserves the order of insertion,  so key/value pais can be iterated in the order they where added","archived":false,"fork":false,"pushed_at":"2017-07-05T09:18:04.000Z","size":72,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-21T15:32:51.698Z","etag":null,"topics":["fifo","go","golang","lifo","ordereddict","orderedmap","pop"],"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/secnot.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":"2017-06-17T10:54:22.000Z","updated_at":"2024-06-21T15:32:51.699Z","dependencies_parsed_at":"2022-09-16T21:12:53.817Z","dependency_job_id":null,"html_url":"https://github.com/secnot/orderedmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/secnot/orderedmap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secnot%2Forderedmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secnot%2Forderedmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secnot%2Forderedmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secnot%2Forderedmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/secnot","download_url":"https://codeload.github.com/secnot/orderedmap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secnot%2Forderedmap/sbom","scorecard":{"id":809037,"data":{"date":"2025-08-11","repo":{"name":"github.com/secnot/orderedmap","commit":"a05363cca499d93a5de6081a1dfc1b35d1c9c9ee"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T12:36:35.441Z","repository_id":57498571,"created_at":"2025-08-23T12:36:35.441Z","updated_at":"2025-08-23T12:36:35.441Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fifo","go","golang","lifo","ordereddict","orderedmap","pop"],"created_at":"2026-01-17T03:02:34.774Z","updated_at":"2026-01-17T03:02:34.944Z","avatar_url":"https://github.com/secnot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OrderedMap [![Build Status](https://travis-ci.org/secnot/orderedmap.svg?branch=master)](https://travis-ci.org/secnot/orderedmap) [![GoDoc](https://godoc.org/github.com/secnot/orderedmap?status.svg)](http://godoc.org/github.com/secnot/orderedmap) [![Go Report Card](https://goreportcard.com/badge/github.com/secnot/orderedmap)](https://goreportcard.com/report/github.com/secnot/orderedmap)\n\nOrderedMap is a Go implentation of Python's OrderedDict class, a map that preserves \nthe order of insertion, so key:value pairs can be iterated in the order they where added.\nIt can also be used as a stack (LIFO) or queue (FIFO).\n\n## Installing\n\nInstall the package from command line with the following command\n\n```bash\ngo get -u github.com/secnot/orderedmap\n```\n\nAnd then import in your source file\n\n```go\nimport \"github.com/secnot/orderedmap\"\n```\n\n\n## Usage\n\n\nBasic operations\n\n```go\npackage main\n\nimport (\n\t\"github.com/secnot/orderedmap\"\n\t\"fmt\"\n)\n\nfunc main() {\n\t// Create\n\tom := orderedmap.NewOrderedMap()\n\n\t// Insert\n\tom.Set(\"John Smith\", 44)\n\tom.Set(\"Laura Paro\", 39)\n\tom.Set(\"Alison Rogers\", 52)\n\n\t// Update\n\tom.Set(\"Alison Rogers\", 51)\n\n\t// Get \n\tif age, ok := om.Get(\"John Smith\"); ok {\n\t\tfmt.Printf(\"John Smith age: %v\", age)\n\t}\n\n\t// Get the last key added\n\tif name, age, ok := om.GetLast() {\n\t\tfmt.Printf(\"%v age: %v\\n\", name, age)\n\t}\n\n\t// Delete\n\tom.Delete(\"John Smith\")\n}\n```\n\nPop the last key from the map\n\n```go\nkey, value, ok := om.PopLast()\n// \u003e Alison Rogers, 52, true\n```\n\nIterate over the Map elements in insertion order\n\n```go\npackage main\n\nimport (\n\t\"github.com/secnot/orderedmap\"\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tom := orderedmap.NewOrderedMap()\n\n\tom.Set(\"John Smith\", 44)\n\tom.Set(\"Laura Paro\", 39)\n\tom.Set(\"Alison Rogers\", 52)\n\n\t// Iterate\n\titer := om.Iter()\n\tfor key, value, ok := iter.Next(); ok; key, value, ok = iter.Next() {\n\t\tfmt.Printf(\"%v: %v\", key, value)\n\t}\n\n\t// \u003e John Smith: 44\n\t// \u003e Laura Paro: 39\n\t// \u003e Alison Rogers: 52\n}\n```\n\nWhile iterating over an OrderedMap only three methods can be called safely,\n**Get**, **Set**, and **Delete**, with some limitations/gotchas for the last\ntwo.\n\n**Set** can update the value of any existing key without problems, but new\nkeys are inserted at the end of the Map so they will be also iterated over, \nthis can cause bugs on innocent-looking code:\n\n```go\npackage main\n\nimport (\n\t\"github.com/secnot/orderedmap\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tom := orderedmap.NewOrderedMap()\n\n\tom.Set(\"John Smith\",  44)\n\tom.Set(\"Laura Paro\",  39)\n\n\t// This is an infinite  loop\n\titer := om.Iter()\n\tfor name, age, ok := iter.Next(); ok; name, age, ok = iter.Next() {\n\t\tom.Set(\"Dr. \" + name, age)\n\t\tfmt.Printf(\"%v\\n\", name)\n\t}\n\n\t// Prints\n\t// \u003e John Smith\n\t// \u003e Laura Paro\n\t// \u003e Dr. John Smith\n\t// \u003e Dr. Laura Paro\n\t// \u003e Dr. Dr. John Smith\n\t// \u003e Dr. Dr. Laura Paro\n\t// .....\n\t\n\t// Iterating in reverse order avoids this problem\n\titer = om.IterReverse()\n\tfor name, age, ok := iter.Next(); ok; name, age, ok = iter.Next() {\n\t\tom.Set(\"Dr. \" + name, age)\n\t}\t\n}\n```\n\n**Delete** is more restrictive and can only be used to delete the key being iterated \nover at that moment.\n\n```go\npackage main\n\nimport \"github.com/secnot/orderedmap\"\n\nfunc main() {\n\n\tom := orderedmap.NewOrderedMap()\n\tom.Set(\"first\", 1)\n\tom.Set(\"second\", 2)\n\tom.Set(\"third\", 3)\n\n\t// This is safe\n\titer := om.Iter()\n\tfor k, _, ok := iter.Next(); ok; k, _, ok = iter.Next() {\n\t\tom.Delete(k)\n\t}\n\n\t// This is NOT\n\titer = om.Iter()\n\tfor _, _, ok := iter.Next(); ok; _, _, ok = iter.Next() {\n\t\tom.Delete(\"another key\")\n\t}\n}\t\t\n\n```\n\nLastly an OrderedMap can also be handled as a queue or a stack with:\n\n* **GetLast** | **GetFirst** : key:value for both ends of the queue or stack, without modifying the map\n* **PopLast**: Pop the value at the top of the Stack.\n* **PopFirst**: Pop next queue element\n* **MoveLast** | **MoveFirst**: Move elements to either end of the queue or stack\n\n\n## Documentation\n\n\n## TYPE\n\n```go\ntype OrderedMap struct {\n\t// contains filtered or unexported fields\n}\n```\n\n#### func NewOrderedMap\n\n```go\nfunc NewOrderedMap() *OrderedMap\n```\nCreate an empty OrderedMap\n\n\n#### func (*OrderedMap) Delete\n\n```go\nfunc (*OrderedMap) Delete(key interface{})\n```\nDelete a key:value pair from the map.\n\n\n#### func (*OrderedMap) Get\n\n```go\nfunc (om *OrderedMap) Get(key interface{}) (value interface{}, ok bool)\n```\nGet the value of an existing key, leaving the map unchanged\n\n\n#### func (om *OrderedMap) GetFirst\n\n```go\nfunc (om *OrderedMap) GetFirst() (key interface{}, value interface{}, ok bool)\n```\nGet the key value for the beginning element, leaving the map unchanged\n\n\n#### func (om *OrderedMap) GetLast\n\n```go\nfunc (om *OrderedMap) GetLast() (key interface{}, value interface{}, ok bool)\n```\nGet the key and value for the last element added, leaving the map\nunchanged\n\n\n#### func (om *OrderedMap) Iter\n\n```go\t\nfunc (om *OrderedMap) Iter() *MapIterator\n```    \nCreate a map iterator\n\n\n#### func (om *OrderedMap) IterReverse\n\n```go\nfunc (om *OrderedMap) IterReverse() *MapIterator\n```\nCreate a reverse order map iterator\n\n\n#### func (om *OrderedMap) Len\n\n```go\nfunc (om *OrderedMap) Len() int\n```\nReturn the number of elements in an OrderedMap\n\n\n#### func (om *OrderedMap) Move\n\n```go\nfunc (om *OrderedMap) Move(key interface{}, last bool) (ok bool)\n```\nMove an existing key to either the end of the OrderedMap\n\n\n#### func (om *OrderedMap) MoveFirst\n\n```go\nfunc (om *OrderedMap) MoveFirst(key interface{}) (ok bool)\n```\nShortcut to Move a key to the beginning of the map\n\n\n#### func (om *OrderedMap) MoveLast\n\n```go\nfunc (om *OrderedMap) MoveLast(key interface{}) (ok bool)\n```\nShortcut to Move a key to the end of the map\n\n\n#### func (om *OrderedMap) Pop\n\n```go\nfunc (om *OrderedMap) Pop(last bool) (key interface{}, value interface{}, ok bool)\n```\n\nPop and return key:value for the newest or oldest element on the OrderedMap.\n\n\n#### func (om *OrderedMap) PopFirst\n\n```go\nfunc (om *OrderedMap) PopFirst() (key interface{}, value interface{}, ok bool)\n```\n\nShortcut to Pop the first element\n\n\n#### func (om *OrderedMap) PopLast\n\n```go\nfunc (om *OrderedMap) PopLast() (key interface{}, value interface{}, ok bool)\n```\nShortcut to Pop the last element\n\n\n#### func (om *OrderedMap) Set\n\n```go\nfunc (om *OrderedMap) Set(key interface{}, value interface{})\n```\nSets the key value, if the key exists it overwrites the existing entry, and\nthe original insertion position is left unchanged, otherwise the key is\ninserted at the end.\n\n\n#### func (om *OrderedMap) String \n\n```go\nfunc (om *OrderedMap) String() string\n```\nStringer interface\n\n\n## Type\n\n```go\ntype MapIterator struct {\n\t// contains filtered or unexported fields\n}\n```\n\n\n#### func (mi *MapIterator) Next\n\n```go\nfunc (mi *MapIterator) Next() (key interface{}, value interface{}, ok bool)\n```    \nReturn iterators next key:value pair until the map is exhausted\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecnot%2Forderedmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecnot%2Forderedmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecnot%2Forderedmap/lists"}