{"id":38272161,"url":"https://github.com/vteromero/bitstream","last_synced_at":"2026-01-17T01:50:42.284Z","repository":{"id":57542075,"uuid":"125639921","full_name":"vteromero/bitstream","owner":"vteromero","description":":zap: Fast bitstream reader/writer :zap:","archived":false,"fork":false,"pushed_at":"2019-01-31T21:55:21.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T11:57:28.816Z","etag":null,"topics":["bits","bitstream","go","golang"],"latest_commit_sha":null,"homepage":null,"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/vteromero.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":"2018-03-17T14:57:08.000Z","updated_at":"2024-06-20T11:57:28.817Z","dependencies_parsed_at":"2022-09-08T23:51:37.555Z","dependency_job_id":null,"html_url":"https://github.com/vteromero/bitstream","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/vteromero/bitstream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vteromero%2Fbitstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vteromero%2Fbitstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vteromero%2Fbitstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vteromero%2Fbitstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vteromero","download_url":"https://codeload.github.com/vteromero/bitstream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vteromero%2Fbitstream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"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":["bits","bitstream","go","golang"],"created_at":"2026-01-17T01:50:41.689Z","updated_at":"2026-01-17T01:50:42.275Z","avatar_url":"https://github.com/vteromero.png","language":"Go","readme":"# bitstream\n\n[![Build Status](https://travis-ci.org/vteromero/bitstream.svg?branch=master)](https://travis-ci.org/vteromero/bitstream)\n[![GoDoc](https://godoc.org/github.com/vteromero/bitstream?status.svg)](https://godoc.org/github.com/vteromero/bitstream)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vteromero/bitstream)](https://goreportcard.com/report/github.com/vteromero/bitstream)\n[![Coverage Status](https://coveralls.io/repos/github/vteromero/bitstream/badge.svg?branch=master)](https://coveralls.io/github/vteromero/bitstream?branch=master)\n\n`bitstream` is a Go library to read and write bit-length values on a stream of bytes.\n\n### Installation\n\n```\n$ go get -v -t github.com/vteromero/bitstream\n```\n\n### Usage\n\nThe [API documentation](https://godoc.org/github.com/vteromero/bitstream) is available on godoc.org.\n\n### Examples\n\nHere is an example of the usage of `bitstream.Reader`:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/vteromero/bitstream\"\n)\n\nfunc showValues(bits uint64, err error) {\n\tfmt.Printf(\"value: %b, error: %v\\n\", bits, err)\n}\n\nfunc main() {\n\tdata := []byte{0x55, 0x55} // in binary: 01010101 01010101\n\n\t// create a new Reader\n\tr := bitstream.NewReader(data)\n\n\t// read 16 bits\n\tbits, err := r.Read(16)\n\tshowValues(bits, err)\n\n\t// reset the Reader to start over\n\tr.Reset()\n\n\t// read bit to bit until EOF\n\tfor {\n\t\tbits, err := r.Read(1)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tbreak\n\t\t}\n\t\tshowValues(bits, err)\n\t}\n}\n```\n\nAnd the following shows how to use `bitstream.Writer`:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/vteromero/bitstream\"\n)\n\nfunc main() {\n\t// create an empty byte slice\n\tdata := make([]byte, 10)\n\n\t// create a new Writer\n\tw := bitstream.NewWriter(data)\n\n\t// some writings\n\tw.Write(0x77665544332211, 56)\n\tw.Write(0x2, 2)\n\tw.Write(0x2, 2)\n\tw.Write(0x2, 2)\n\tw.Write(0x2, 2)\n\tw.Write(0xb, 4)\n\tw.Write(0xb, 4)\n\tw.Write(0xcc, 8)\n\n\tfmt.Printf(\"% x\\n\", data)\n}\n```\n\n### Benchmarks\n\nYou can test the performance of the library in this way:\n\n```\n$ cd $GOPATH/src/github.com/vteromero/bitstream\n$ go test -run=^$ -bench=.\n```\n\nAs a reference, here is the outcome on a laptop Ubuntu Desktop 18.10 with a Core i7-6700HQ CPU @ 2.60GHz x 8\n\n```\nBenchmarkRead/SmallSizes-8         \t100000000\t        16.3 ns/op\nBenchmarkRead/MediumSizes-8        \t100000000\t        16.3 ns/op\nBenchmarkRead/LargeSizes-8         \t100000000\t        16.3 ns/op\nBenchmarkRead/ExtraLargeSizes-8    \t100000000\t        16.3 ns/op\nBenchmarkRead/AllSizes-8           \t100000000\t        16.3 ns/op\nBenchmarkWrite/SmallSizes-8        \t100000000\t        17.0 ns/op\nBenchmarkWrite/MediumSizes-8       \t100000000\t        17.0 ns/op\nBenchmarkWrite/LargeSizes-8        \t100000000\t        17.0 ns/op\nBenchmarkWrite/ExtraLargeSizes-8   \t100000000\t        17.0 ns/op\nBenchmarkWrite/AllSizes-8          \t100000000\t        17.0 ns/op\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvteromero%2Fbitstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvteromero%2Fbitstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvteromero%2Fbitstream/lists"}