{"id":23408576,"url":"https://github.com/pektezol/bitreader","last_synced_at":"2025-10-26T14:32:36.159Z","repository":{"id":58843541,"uuid":"532208591","full_name":"pektezol/bitreader","owner":"pektezol","description":"The simplest bit reader library with big/little-endian support for Golang.","archived":false,"fork":false,"pushed_at":"2023-09-16T11:00:01.000Z","size":73,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-17T18:43:35.246Z","etag":null,"topics":["bitreader","bitwise","endianness","go","golang","library"],"latest_commit_sha":null,"homepage":"https://blog.pektezol.dev/posts/20230917_bitreader.html","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pektezol.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}},"created_at":"2022-09-03T09:04:03.000Z","updated_at":"2024-10-31T09:40:47.000Z","dependencies_parsed_at":"2024-06-20T04:22:30.949Z","dependency_job_id":"d6dad3e9-d95d-45af-a8fa-0151dcf1320b","html_url":"https://github.com/pektezol/bitreader","commit_stats":null,"previous_names":["bisaxa/bitreader"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/pektezol/bitreader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pektezol%2Fbitreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pektezol%2Fbitreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pektezol%2Fbitreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pektezol%2Fbitreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pektezol","download_url":"https://codeload.github.com/pektezol/bitreader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pektezol%2Fbitreader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268718608,"owners_count":24295952,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"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":["bitreader","bitwise","endianness","go","golang","library"],"created_at":"2024-12-22T15:15:51.708Z","updated_at":"2025-10-26T14:32:36.059Z","avatar_url":"https://github.com/pektezol.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BitReader [![Go Reference](https://pkg.go.dev/badge/github.com/pektezol/bitreader.svg)](https://pkg.go.dev/github.com/pektezol/bitreader) [![Go Report Card](https://goreportcard.com/badge/github.com/pektezol/bitreader)](https://goreportcard.com/report/github.com/pektezol/bitreader) [![License: LGPL 2.1](https://img.shields.io/badge/License-LGPL_v2.1-blue.svg)](https://github.com/pektezol/bitreader/blob/main/LICENSE) \nThe simplest bit reader with big/little-endian support for Golang.\n\n## Installation\n```bash\n$ go get github.com/pektezol/bitreader\n```\n\n## Usage Examples\n\n```go\nimport \"github.com/pektezol/bitreader\"\n\n// ioStream:        io.Reader  Data to read from an io stream\n// byteStream:      []byte     Data to read from a byte slice\n// littleEndian:    bool       Little-endian(true) or big-endian(false) state\nreader := bitreader.NewReader(ioStream, le)\nreader := bitreader.NewReaderFromBytes(byteStream, le)\n\n// Fork Reader, Copies Current Reader\nnewReader, err := reader.Fork()\n\n// Read Total Number of Bits Left\nbits, err := reader.ReadRemainingBits()\n\n// Read First Bit\nstate, err := reader.ReadBool()\n\n// Read Bits/Bytes\nvalue, err := reader.ReadBits(64)       // up to 64 bits\nvalue, err := reader.ReadBytes(8)       // up to 8 bytes\n\n// Read String\ntext, err := reader.ReadString()            // null-terminated\ntext, err := reader.ReadStringLength(256)   // length-specified\n\n// Read Bits/Bytes into Slice\narr, err := reader.ReadBitsToSlice(128)\narr, err := reader.ReadBytesToSlice(64)\n\n// Skip Bits/Bytes\nerr := reader.SkipBits(8)\nerr := reader.SkipBytes(4)\n\n// Wrapper functions\nstate := reader.TryReadBool()           // bool\nvalue := reader.TryReadInt1()           // uint8\nvalue := reader.TryReadUInt8()          // uint8\nvalue := reader.TryReadSInt8()          // int8\nvalue := reader.TryReadUInt16()         // uint16\nvalue := reader.TryReadSInt16()         // int16\nvalue := reader.TryReadUInt32()         // uint32\nvalue := reader.TryReadSInt32()         // int32\nvalue := reader.TryReadUInt64()         // uint64\nvalue := reader.TryReadSInt64()         // int64\nvalue := reader.TryReadFloat32()        // float32\nvalue := reader.TryReadFloat64()        // float64\nvalue := reader.TryReadBits(64)         // uint64\nvalue := reader.TryReadBytes(8)         // uint64\ntext := reader.TryReadString()          // string\ntext := reader.TryReadStringLength(64)  // string\narr := reader.TryReadBitsToSlice(1024)  // []byte\narr := reader.TryReadBytesToSlice(128)  // []byte\nbits := reader.TryReadRemainingBits()   // uint64\n```\n\n## Error Handling\nAll ReadXXX(), SkipXXX() and Fork() functions returns an error message when they don't work as expected. It is advised to always handle errors. \\\nWrapper functions, however, only returns the value and panics if an error is encountered, for the sake of ease of use.\n\n## Bug Report / Feature Request\nUsing [Github Issues](https://github.com/pektezol/BitReader/issues/new/choose), you can report a bug that you encountered and/or request a feature that you would like to be added.\n\n## Documentation\n\nFull documentation can be found in https://pkg.go.dev/github.com/pektezol/bitreader\n\n## License\nThis project is licensed under [GNU Lesser General Public License version 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpektezol%2Fbitreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpektezol%2Fbitreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpektezol%2Fbitreader/lists"}