{"id":15501408,"url":"https://github.com/fgm/container","last_synced_at":"2026-04-08T12:02:20.780Z","repository":{"id":38007867,"uuid":"488979761","full_name":"fgm/container","owner":"fgm","description":"Type-safe implementations of OrderedMap, Queue, Set and Stack using Go generics","archived":false,"fork":false,"pushed_at":"2026-04-05T10:22:05.000Z","size":242,"stargazers_count":2,"open_issues_count":8,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-05T12:14:34.659Z","etag":null,"topics":["generics","orderedmap","queue","set","stack"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fgm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":"COPYRIGHT.txt","agents":null,"dco":null,"cla":null}},"created_at":"2022-05-05T13:17:39.000Z","updated_at":"2026-04-05T10:22:02.000Z","dependencies_parsed_at":"2025-03-24T22:21:03.639Z","dependency_job_id":"cb379c4d-466b-4260-b0e0-fd11c8911ddf","html_url":"https://github.com/fgm/container","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fgm/container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgm%2Fcontainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgm%2Fcontainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgm%2Fcontainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgm%2Fcontainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fgm","download_url":"https://codeload.github.com/fgm/container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgm%2Fcontainer/sbom","scorecard":{"id":660278,"data":{"date":"2025-08-21T14:20:38Z","repo":{"name":"github.com/fgm/container","commit":"d89a8c8391adc141a624cae495118f1ce0652f86"},"scorecard":{"version":"v5.2.1","commit":"ab2f6e92482462fe66246d9e32f642855a691dc1"},"score":9.4,"checks":[{"name":"Code-Review","score":5,"reason":"Found 2/4 approved changesets -- score normalized to 5","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/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#code-review"}},{"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/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#packaging"}},{"name":"Maintained","score":10,"reason":"23 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#maintained"}},{"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/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#binary-artifacts"}},{"name":"Dependency-Update-Tool","score":10,"reason":"update tool detected","details":["Info: detected update tool: Dependabot: .github/dependabot.yml:1"],"documentation":{"short":"Determines if the project uses a dependency update tool.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dependency-update-tool"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#security-policy"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: jobLevel 'packages' permission set to 'read': .github/workflows/codeql.yml:42","Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:45","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:46","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/update.yml:17","Info: topLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:26","Info: topLevel 'contents' permission set to 'read': .github/workflows/dependency-review.yml:13","Info: topLevel permissions set to 'read-all': .github/workflows/scorecard.yml:18","Info: topLevel 'contents' permission set to 'read': .github/workflows/update.yml:12","Info: topLevel 'contents' permission set to 'read': .github/workflows/workflow.yml:9"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":10,"reason":"all dependencies are pinned","details":["Info:  13 out of  13 GitHub-owned GitHubAction dependencies pinned","Info:   8 out of   8 third-party GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#license"}},{"name":"CII-Best-Practices","score":5,"reason":"badge detected: Passing","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#cii-best-practices"}},{"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/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: SAST configuration detected: CodeQL","Info: all commits (30) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#sast"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: GoBuiltInFuzzer integration found: set/basic_map_test.go:470","Info: GoBuiltInFuzzer integration found: set/basic_map_test.go:514","Info: GoBuiltInFuzzer integration found: set/basic_map_test.go:556"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#fuzzing"}},{"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/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#branch-protection"}},{"name":"Contributors","score":10,"reason":"project has 3 contributing companies or organizations -- score normalized to 10","details":["Info: found contributions from: OSInet, osinet, stepsecurity"],"documentation":{"short":"Determines if the project has a set of contributors from multiple organizations (e.g., companies).","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#contributors"}},{"name":"CI-Tests","score":10,"reason":"24 out of 24 merged PRs checked by a CI test -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project runs tests before pull requests are merged.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#ci-tests"}}]},"last_synced_at":"2025-08-21T15:57:27.575Z","repository_id":38007867,"created_at":"2025-08-21T15:57:27.576Z","updated_at":"2025-08-21T15:57:27.576Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31554110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["generics","orderedmap","queue","set","stack"],"created_at":"2024-10-02T09:04:14.900Z","updated_at":"2026-04-08T12:02:20.717Z","avatar_url":"https://github.com/fgm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go containers\n\n[![GoDoc](https://pkg.go.dev/badge/github.com/fgm/container)](https://pkg.go.dev/github.com/fgm/container)\n[![Go Report Card](https://goreportcard.com/badge/github.com/fgm/container)](https://goreportcard.com/report/github.com/fgm/container)\n[![github](https://github.com/fgm/container/actions/workflows/workflow.yml/badge.svg)](https://github.com/fgm/container/actions/workflows/workflow.yml)\n[![codecov](https://codecov.io/gh/fgm/container/branch/main/graph/badge.svg?token=8YYX1B720M)](https://codecov.io/gh/fgm/container)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/fgm/container/badge)](https://securityscorecards.dev/viewer/?uri=github.com/fgm/container)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10245/badge)](https://www.bestpractices.dev/projects/10245)\n\nThis module contains minimal type-safe Ordered Map, Queue, Set and Stack implementations\nusing Go generics.\n\nThe Ordered Map supports both stable (in-place) updates and recency-based ordering,\nmaking it suitable both for highest performance (in-place), and for LRU caches (recency).\n\n## Contents\n\nSee the available types by underlying storage\n\n| Type          | Slice | Map | List | List+sync.Pool | List+int. pool | Recommended          |\n|---------------|:-----:|:---:|:----:|:--------------:|:--------------:|----------------------|\n| OrderedMap    |   Y   |     |      |                |                | Slice with size hint |\n| Queue         |   Y   |     |  Y   |       Y        |       Y        | Slice with size hint |\n| WaitableQueue |   Y   |     |      |                |                | Slice with size hint |\n| Set           |       |  Y  |      |                |                | Map with size hint   |\n| Stack         |   Y   |     |  Y   |       Y        |       Y        | Slice with size hint |\n\n\n**CAVEAT**: In order to optimize performance, except for WaitableQueue,\nall of these implementations are unsafe for concurrent execution,\nso they need protection in concurrency situations.\n\nWaitableQueue being designed for concurrent code, on the other hand, is concurrency-safe.\n\nGenerally speaking, in terms of performance:\n\n- Slice \u003e list+internal pool \u003e plain List \u003e list+sync.Pool\n- Preallocated \u003e not preallocated\n\nSee [BENCHARKS.md](BENCHMARKS.md) for details.\n\n## Usage\n\nSee complete listings in:\n\n- [`cmd/orderedmap`](cmd/orderedmap/real_main.go)\n- [`cmd/queuestack`](cmd/queuestack/real_main.go)\n- [`cmd/set`](cmd/set/real_main.go)\n\n### Ordered Map\n\n```go\nstable := true\nom := orderedmap.NewSlice[Key, Value](sizeHint, stable) // OrderedMap and Countable\nom.Store(k, v)\nom.Range(func (k K, v V) bool { fmt.Println(k, v); return true })\nv, loaded := om.Load(k)\nif !loaded {\n        fmt.Fprintf(w, \"No entry for key %v\\n\", k)\n}\nom.Delete(k) // Idempotent: does not fail on nonexistent keys.\n```\n\n### Classic Queues without flow control\n\n```go\nvar e Element\nq := queue.NewSliceQueue[Element](sizeHint)\nq.Enqueue(e)\nif lq, ok := q.(container.Countable); ok {\n        fmt.Fprintf(w, \"elements in queue: %d\\n\", lq.Len())\n}\nfor i := 0; i \u003c 2; i++ {\n        e, ok := q.Dequeue()\n        fmt.Fprintf(w, \"Element: %v, ok: %t\\n\", e, ok)\n}\n```\n\n### WaitableQueue: a concurrent queue with flow control\n\n```go\nvar e Element\nq, _ := queue.NewWaitableQueue[Element](sizeHint, lowWatermark, highWatermark)\ngo func() {\n        wqs := q.Enqueue(e)\n        if lq, ok := q.(container.Countable); ok {\n                fmt.Fprintf(w, \"elements in queue: %d, status: %s\\n\", lq.Len(), wqs)\n        }\n}\n\u003c-q.WaitChan()                    // Wait for elements to be available to dequeue\nfor i := 0; i \u003c 2; i++ {          // Then dequeue them\n        e, ok, wqs := q.Dequeue() // Non-blocking, ok will be true for the first and false for the second \n        fmt.Fprintf(w, \"Element: %v, ok: %t, status: %s\\n\", e, ok, wqs)\n}\nq.Close() // Only needed if consumers may still be waiting on \u003c-q.WaitChan\n```\n\n### Sets\n\n```go\nvar e Element\ns := set.NewBasicMap[Element](sizeHint)\ns.Add(e)\ns.Add(e)\nif cs, ok := q.(container.Countable); ok {\n        fmt.Fprintf(w, \"elements in set: %d\\n\", cs.Len()) // 1\n}\nfor e := range s.Items() {\n        fmt.Fprintln(w, e)\n}\n\n```\n\n### Stacks\n\n```go\ns := stack.NewSliceStack[Element](sizeHint)\ns.Push(e)\nif ls, ok := s.(container.Countable); ok {\n        fmt.Printf(\"elements in stack: %d\\n\", ls.Len())\n}\nfor i := 0; i \u003c 2; i++ {\n        e, ok := s.Pop()\n        fmt.Printf(\"Element: %v, ok: %t\\n\", e, ok)\n}\n```\n\n### Development\n\nSince this is a library, it has no install process, but you can build it to ensure correctness, with:\n\n```\n    make lint      # Run staticcheck linting checks\n    make build     # Build the library. Include test and fuzz-smoke targets.\n    make           # Shortcut for make lint \u0026\u0026 make build\n```\n\n#### Running normal tests: unit and benchmarks\n\nFor the simple version, without generating coverage reports, run:\n```\n    make test       # Unit tests, fast\n    make coverage   # Coverage report in cover.out. A bit longer.\n    make bench      # Benchmarks: run to update BENCHMARKS.md\n    make fuzz-smoke # Fuzz tests as smoke tests: 10 seconds only, for CI builds\n```\n\nThis will also run the fuzz tests in unit test mode, \nwithout triggering the fuzzing logic.\n\n\n#### Running fuzz tests\n\nFuzz tests are not run by CI, but you can run them on-demand during development with:\n\n```\n    go test -fuzz='\\QFuzzBasicMapAdd\\E'   -fuzztime=20s ./set\n    go test -fuzz='\\QFuzzBasicMapItems\\E' -fuzztime=20s ./set\n    go test -fuzz='\\QFuzzBasicMapUnion\\E' -fuzztime=20s ./set\n``` \n\n- Adjust `-fuzztime` duration as relevant: 20 seconds is just a smoke test.\n- Be sure to escape the `\\Q\\E` characters in the `-fuzz` argument in your shell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgm%2Fcontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgm%2Fcontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgm%2Fcontainer/lists"}