{"id":41178507,"url":"https://github.com/aohorodnyk/binflags","last_synced_at":"2026-01-22T20:01:59.648Z","repository":{"id":48865232,"uuid":"315729928","full_name":"aohorodnyk/binflags","owner":"aohorodnyk","description":"Bitset library provides implementation for all int/uint types and arrays and maps","archived":false,"fork":false,"pushed_at":"2023-03-14T06:50:37.000Z","size":226,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-19T17:50:52.926Z","etag":null,"topics":["binary-flags","binflags","bitset","bitset-array","bitset-library","bitset-map","flag","flags","flagset","go","golang","golang-library","golang-module"],"latest_commit_sha":null,"homepage":"https://anton.ohorodnyk.name/blog/2021-01-03-binary-flags/","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/aohorodnyk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-11-24T19:15:58.000Z","updated_at":"2023-03-11T16:41:29.000Z","dependencies_parsed_at":"2024-06-19T17:27:05.177Z","dependency_job_id":null,"html_url":"https://github.com/aohorodnyk/binflags","commit_stats":null,"previous_names":["aohorodnyk/gobitflags"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/aohorodnyk/binflags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aohorodnyk%2Fbinflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aohorodnyk%2Fbinflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aohorodnyk%2Fbinflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aohorodnyk%2Fbinflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aohorodnyk","download_url":"https://codeload.github.com/aohorodnyk/binflags/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aohorodnyk%2Fbinflags/sbom","scorecard":{"id":200862,"data":{"date":"2025-08-11","repo":{"name":"github.com/aohorodnyk/binflags","commit":"b9ceb40bda2d68dc2e851e6218436ca2e683a8de"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/11 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":"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":"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":"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/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"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":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/aohorodnyk/binflags/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/aohorodnyk/binflags/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/aohorodnyk/binflags/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/aohorodnyk/binflags/go.yml/main?enable=pin","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction 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/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":"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":"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":"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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"}}]},"last_synced_at":"2025-08-16T22:47:57.104Z","repository_id":48865232,"created_at":"2025-08-16T22:47:57.104Z","updated_at":"2025-08-16T22:47:57.104Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28670288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T19:36:09.361Z","status":"ssl_error","status_checked_at":"2026-01-22T19:36:05.567Z","response_time":144,"last_error":"SSL_read: 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":["binary-flags","binflags","bitset","bitset-array","bitset-library","bitset-map","flag","flags","flagset","go","golang","golang-library","golang-module"],"created_at":"2026-01-22T20:01:56.191Z","updated_at":"2026-01-22T20:01:59.637Z","avatar_url":"https://github.com/aohorodnyk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang bitset library\n\n[![GitHub Workflow Status](https://github.com/aohorodnyk/binflags/actions/workflows/go.yml/badge.svg)](https://github.com/aohorodnyk/binflags/actions/workflows/go.yml)\n[![License](https://img.shields.io/github/license/aohorodnyk/binflags)](https://github.com/aohorodnyk/binflags/blob/main/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/aohorodnyk/binflags)](https://github.com/aohorodnyk/binflags/issues)\n[![GitHub issues](https://img.shields.io/github/issues-pr/aohorodnyk/binflags)](https://github.com/aohorodnyk/binflags/pulls)\n[![The latest release version](https://img.shields.io/github/v/release/aohorodnyk/binflags)](https://github.com/aohorodnyk/binflags/releases)\n[![GoDoc](https://godoc.org/github.com/aohorodnyk/binflags?status.svg)](https://pkg.go.dev/github.com/aohorodnyk/binflags)\n\n- [Golang bitset library](#golang-bitset-library)\n  - [Golang 1.18](#golang-118)\n  - [Motivation](#motivation)\n  - [Examples](#examples)\n    - [Dynamic](#dynamic)\n    - [Fixed](#fixed)\n    - [Sync](#sync)\n    - [Examples in unit tests](#examples-in-unit-tests)\n  - [Contributing](#contributing)\n    - [Branch Name](#branch-name)\n    - [Git Hook](#git-hook)\n\n## Golang 1.18\n\nThe package was built to use Go 1.18 with generics. If you need older version, see please the version [v0.0.3](https://github.com/aohorodnyk/binflags/releases/tag/v0.0.3).\n\n## Motivation\n\nCreating a robust bitset implementation for various types, including \"Big Flags\" through the use of a map or array of INTs, is a crucial necessity in many applications. While the implementation process is straightforward, it requires thorough testing and support to ensure reliable functionality. As such, careful attention is necessary during the implementation, testing, and maintenance stages to deliver a high-quality and dependable solution.\n\nAfter few time of implementation I made a decision to extract the feature into open-source library which should meet number of requirements:\n\n1. :white_check_mark: It should support all INT types\n1. :white_check_mark: It should be implemented for \"Big Flags\" tasks through array and map\n1. :white_check_mark: It should be well testes, in ideal world it should be with 100% of coverage\n\n## Examples\n\n### Dynamic\n\nDynamic type is a `map[uint]T`, where `T` is any integer type. This type is a perfect match to the situation when flags are not sequence and we can assign an any random flag to a user (in range of `uin32 * sizeof(T)`).\n\n```go\n\tflags := make(binflags.Dynamic[uint8], 3)\n\tfmt.Println(flags)\n\tfmt.Println(flags.Set(436235346))\n\tfmt.Println(flags.Set(0))\n\tfmt.Println(flags.Set(52))\n\tfmt.Println(flags.Set(3462363))\n\tfmt.Println(flags.Set(9874563524235))\n\tfmt.Println(flags)\n\tfmt.Println(flags.IsSet(0))\n\tfmt.Println(flags.IsSet(52))\n\tfmt.Println(flags.IsSet(3462363))\n\tfmt.Println(flags.IsSet(9874563524235))\n\tfmt.Println(flags.IsSet(436235346))\n\tfmt.Println(flags.IsSet(1))\n\tfmt.Println(flags.IsSet(436235345))\n\tfmt.Println(flags.IsSet(436235347))\n\tfmt.Println(flags.Unset(0))\n\tfmt.Println(flags.Unset(9874563524235))\n\tfmt.Println(flags.Unset(2523))\n\tfmt.Println(flags)\n\n\t// Output:\n\t// map[]\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// map[0:1 6:16 432795:8 54529418:4 1234320440529:8]\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// false\n\t// false\n\t// false\n\t// true\n\t// true\n\t// true\n\t// map[6:16 432795:8 54529418:4]\n```\n\n### Fixed\n\nFixed type uses an `array[T]` to save flags. It's more efficient if more sequent list of flags will be used.\n\n```go\nfunc ExampleFixed() {\n\tflags := make(binflags.Fixed[uint8], 3)\n\tfmt.Println(flags)\n\tfmt.Println(flags.Set(20))\n\tfmt.Println(flags)\n\tfmt.Println(flags.Set(23))\n\tfmt.Println(flags)\n\tfmt.Println(flags.Set(13))\n\tfmt.Println(flags)\n\tfmt.Println(flags.Set(24))\n\tfmt.Println(flags)\n\tfmt.Println(flags.IsSet(5))\n\tfmt.Println(flags.IsSet(13))\n\tfmt.Println(flags.Unset(24))\n\tfmt.Println(flags)\n\tfmt.Println(flags.Unset(7))\n\tfmt.Println(flags)\n\tfmt.Println(flags.Unset(13))\n\tfmt.Println(flags)\n\n\t// Output:\n\t// [0 0 0]\n\t// true\n\t// [0 0 16]\n\t// true\n\t// [0 0 144]\n\t// true\n\t// [0 32 144]\n\t// false\n\t// [0 32 144]\n\t// false\n\t// true\n\t// false\n\t// [0 32 144]\n\t// true\n\t// [0 32 144]\n\t// true\n\t// [0 0 144]\n}\n```\n\n### Sync\n\n`Sync` type is a decorator on top of `Dynamic` and `Fixed` types. Just cover any of them and use concurrenctly.\n\nThis type uses **RWMutex**, because of usually services have much more reads than writes.\n\n```go\nfunc ExampleSync() {\n\tflags := binflags.NewSync(\u0026binflags.Dynamic[uint8]{})\n\tfmt.Println(flags.Set(436235346))\n\tfmt.Println(flags.Set(0))\n\tfmt.Println(flags.Set(52))\n\tfmt.Println(flags.Set(3462363))\n\tfmt.Println(flags.Set(9874563524235))\n\tfmt.Println(flags.IsSet(0))\n\tfmt.Println(flags.IsSet(52))\n\tfmt.Println(flags.IsSet(3462363))\n\tfmt.Println(flags.IsSet(9874563524235))\n\tfmt.Println(flags.IsSet(436235346))\n\tfmt.Println(flags.IsSet(1))\n\tfmt.Println(flags.IsSet(436235345))\n\tfmt.Println(flags.IsSet(436235347))\n\tfmt.Println(flags.Unset(0))\n\tfmt.Println(flags.Unset(9874563524235))\n\tfmt.Println(flags.Unset(2523))\n\n\t// Output:\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// true\n\t// false\n\t// false\n\t// false\n\t// true\n\t// true\n\t// true\n}\n```\n\n### Examples in unit tests\n\nFull list of examples can be found in `*_test.go` files. This library has coverage ~100%, and I'm gonna keep the level.\n\nAnd, do not forget to use [GoDoc](https://pkg.go.dev/github.com/aohorodnyk/binflags)!\n\n## Contributing\n\nThe library is open source and you can contribute to it.\n\nBefore contrbution, make sure that githook is configured for you and all your commits contain the correct issue tag.\n\n### Branch Name\n\nBefore you start the contribution, make sure that you are on the correct branch. Branch name should start from the issue number dash and short explanation with spaces replaced by underscores. Example:\n\n- `1-my_feature`\n- `2-fix_bug`\n- `234-my_important_pr`\n\n### Git Hook\n\nTo configure the git hook, you need to simply run the command: `git config core.hooksPath .githooks`\n\nIt will configure the git hook to run the `pre-commit` script. Source code of the hook is in `.githooks/prepare-commit-msg`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faohorodnyk%2Fbinflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faohorodnyk%2Fbinflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faohorodnyk%2Fbinflags/lists"}