{"id":18053777,"url":"https://github.com/hymkor/go-bitfield","last_synced_at":"2026-03-02T07:02:46.967Z","repository":{"id":65436144,"uuid":"592323474","full_name":"hymkor/go-bitfield","owner":"hymkor","description":"The C-like Bitfield packing/unpacking library on Golang","archived":false,"fork":false,"pushed_at":"2023-01-23T16:10:09.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-18T22:41:51.903Z","etag":null,"topics":["bitfield","bitfields","go","golang","reflect"],"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/hymkor.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":"2023-01-23T13:41:13.000Z","updated_at":"2024-07-02T13:44:20.000Z","dependencies_parsed_at":"2023-02-13T00:40:13.850Z","dependency_job_id":null,"html_url":"https://github.com/hymkor/go-bitfield","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hymkor/go-bitfield","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Fgo-bitfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Fgo-bitfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Fgo-bitfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Fgo-bitfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hymkor","download_url":"https://codeload.github.com/hymkor/go-bitfield/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Fgo-bitfield/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29994618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"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":["bitfield","bitfields","go","golang","reflect"],"created_at":"2024-10-31T00:08:01.744Z","updated_at":"2026-03-02T07:02:46.942Z","avatar_url":"https://github.com/hymkor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-bitfield\r\n===========\r\n\r\n- `Pack` and `Unpack` :\r\n    - convert between uint64 and structure\r\n- `PackInline` and `UnpackInline` :\r\n    - convert between uint64 and array.\r\n\r\n```go\r\npackage bitfield_test\r\n\r\nimport (\r\n    \"testing\"\r\n\r\n    \"github.com/hymkor/go-bitfield\"\r\n)\r\n\r\nconst packedValue = 0x7423\r\n\r\ntype DosDate struct {\r\n    Second int  `bit:\"5\"`\r\n    Min    uint `bit:\"6\"`\r\n    Hour   int  `bit:\"5\"`\r\n}\r\n\r\nfunc TestUnpack(t *testing.T) {\r\n    var dt DosDate\r\n    if err := bitfield.Unpack(uint64(packedValue), \u0026dt); err != nil {\r\n        t.Fatal(err.Error())\r\n        return\r\n    }\r\n    if dt.Second != 3 {\r\n        t.Fatalf(\"Second: expect 3, but %d\", dt.Second)\r\n    }\r\n    if dt.Min != 33 {\r\n        t.Fatalf(\"Min: expect 33, but %d\", dt.Min)\r\n    }\r\n    if dt.Hour != 14 {\r\n        t.Fatalf(\"Hour: expect 14,but %d\", dt.Hour)\r\n    }\r\n}\r\n\r\nfunc TestPack(t *testing.T) {\r\n    var dt = \u0026DosDate{\r\n        Second: 3,\r\n        Min:    33,\r\n        Hour:   14,\r\n    }\r\n\r\n    value, err := bitfield.Pack(dt)\r\n    if err != nil {\r\n        t.Fatalf(\"pack: %s\", err.Error())\r\n    }\r\n    if value != packedValue {\r\n        t.Fatalf(\"pack: expect %d, but %d\", packedValue, value)\r\n    }\r\n}\r\n\r\nconst (\r\n    secondBit = 5\r\n    minBit    = 6\r\n    hourBit   = 5\r\n)\r\n\r\nfunc TestUnpackInline(t *testing.T) {\r\n    dt := bitfield.UnpackInline(packedValue, secondBit, minBit, hourBit)\r\n    if dt[0] != 3 {\r\n        t.Fatalf(\"Second: expect 3, but %d\", dt[0])\r\n    }\r\n    if dt[1] != 33 {\r\n        t.Fatalf(\"Min: expect 33, but %d\", dt[1])\r\n    }\r\n    if dt[2] != 14 {\r\n        t.Fatalf(\"Hour: expect 14,but %d\", dt[2])\r\n    }\r\n}\r\n\r\nfunc TestPackInline(t *testing.T) {\r\n    dt := bitfield.PackInline(secondBit, 3, minBit, 33, hourBit, 14)\r\n    if dt != packedValue {\r\n        t.Fatalf(\"PackInline expect %d,but %d\", packedValue, dt)\r\n    }\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Fgo-bitfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhymkor%2Fgo-bitfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Fgo-bitfield/lists"}