{"id":29480971,"url":"https://github.com/asmsh/flagged","last_synced_at":"2025-07-14T23:55:14.055Z","repository":{"id":304570359,"uuid":"1019174128","full_name":"asmsh/flagged","owner":"asmsh","description":"Overthinking per-bool overhead? Turn bool-heavy structs into compact, typed bitflags for Go — fast, zero-alloc, and go:generate–friendly.","archived":false,"fork":false,"pushed_at":"2025-07-13T23:40:53.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-14T00:30:42.035Z","etag":null,"topics":["bitflags","bitmask","bitwise","codegen","config","flags","golang"],"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/asmsh.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,"zenodo":null}},"created_at":"2025-07-13T22:43:44.000Z","updated_at":"2025-07-13T23:40:56.000Z","dependencies_parsed_at":"2025-07-14T00:30:45.773Z","dependency_job_id":"c8af67d8-7206-40e1-b6fa-ca291c0568fd","html_url":"https://github.com/asmsh/flagged","commit_stats":null,"previous_names":["asmsh/flagged"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/asmsh/flagged","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fflagged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fflagged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fflagged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fflagged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asmsh","download_url":"https://codeload.github.com/asmsh/flagged/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmsh%2Fflagged/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265288821,"owners_count":23741251,"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":["bitflags","bitmask","bitwise","codegen","config","flags","golang"],"created_at":"2025-07-14T23:55:13.545Z","updated_at":"2025-07-14T23:55:14.047Z","avatar_url":"https://github.com/asmsh.png","language":"Go","readme":"### flagged is a lightweight, fast, and zero-alloc Go library for working with typed, compact bitflags.\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/asmsh/flagged)](https://pkg.go.dev/github.com/asmsh/flagged)\n[![Go Report Card](https://goreportcard.com/badge/github.com/asmsh/flagged)](https://goreportcard.com/report/github.com/asmsh/flagged)\n[![Tests](https://github.com/asmsh/flagged/workflows/Tests/badge.svg)](https://github.com/asmsh/flagged/actions)\n[![Go Coverage](https://github.com/asmsh/flagged/wiki/coverage.svg)](https://raw.githack.com/wiki/asmsh/flagged/coverage.html)\n\nIt provides a minimal, extensible API for manipulating and inspecting compact bitflags, while remaining dependency-free and allocation-free.\n\nIt’s ideal for scenarios where you need efficient and compact boolean state representation — whether for generated flags, boolean configurations, or packed state machines.\n\n### Features:\n\n* Exposes typed wrappers for `uint` types: `BitFlags8`, `BitFlags16`, `BitFlags32`, `BitFlags64` (matching `uint8`, `uint16`, `uint32`, `uint64`, respectively).\n* Unified interface: all exposed types implement a common BitFlags interface\n* Core bit operations, using only the bit index (normal integers, with no shifting required for inputs).\n* Pure Go implementation, no reflection, no dependencies, suitable for any application, in any environment.\n* `go:generate`–friendly: easy to use directly or as a backend for code generators (check [genflagged](https://pkg.go.dev/github.com/asmsh/flagged/cmd/genflagged)).\n\n### Installation:\n\n```shell\ngo get github.com/asmsh/flagged\n```\n\n### Usage:\n\nImport the package:\n\n```go\nimport \"github.com/asmsh/flagged\"\n```\n\nChoose a bit width depending on your needs:\n\n```go\nvar flags flagged.BitFlags16\nflags.Set(3)\nif flags.Is(3) {\n    fmt.Println(\"flags[3] is set\")\n}\nflags.Reset(3)\nif !flags.Is(3) {\n    fmt.Println(\"flags[3] is not set\")\n}\n```\n\nOr work with the interface:\n\n```go\nvar f flagged.BitFlags = flagged.New(flagged.BitFlags32(0))\nf.Set(1)\nf.Set(5)\nf.Toggle(1)\nfmt.Println(f) // 00000000000000000000000000100000\n```\n\n### Example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/asmsh/flagged\"\n)\n\nconst (\n\tpermissionReadBitIndex flagged.BitIndex = iota\n\tpermissionWriteBitIndex\n\tpermissionExecBitIndex\n)\n\nfunc main() {\n\tvar permFlags flagged.BitFlags8\n\tpermFlags.Set(permissionReadBitIndex)\n\tpermFlags.Set(permissionExecBitIndex)\n\n\tfmt.Println(permFlags.Is(permissionReadBitIndex))  // true\n\tfmt.Println(permFlags.Is(permissionWriteBitIndex)) // false\n\n\tpermFlags.Toggle(permissionWriteBitIndex)\n\tfmt.Println(permFlags.Is(permissionWriteBitIndex)) // true\n\n\tfmt.Println(permFlags) // 00000111\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmsh%2Fflagged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmsh%2Fflagged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmsh%2Fflagged/lists"}