{"id":20843100,"url":"https://github.com/pdgendt/cobs","last_synced_at":"2025-04-10T16:05:47.106Z","repository":{"id":240193496,"uuid":"801057996","full_name":"pdgendt/cobs","owner":"pdgendt","description":"A Golang implementation for COBS","archived":false,"fork":false,"pushed_at":"2025-04-08T09:07:10.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T10:22:55.137Z","etag":null,"topics":["cobs","golang"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pdgendt/cobs","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/pdgendt.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":"2024-05-15T14:07:04.000Z","updated_at":"2025-04-08T09:07:07.000Z","dependencies_parsed_at":"2025-04-08T10:22:07.783Z","dependency_job_id":"1823dc82-177b-4489-bb70-2308cb0a14ac","html_url":"https://github.com/pdgendt/cobs","commit_stats":null,"previous_names":["pdgendt/cobs"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdgendt%2Fcobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdgendt%2Fcobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdgendt%2Fcobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdgendt%2Fcobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdgendt","download_url":"https://codeload.github.com/pdgendt/cobs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248250738,"owners_count":21072680,"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":["cobs","golang"],"created_at":"2024-11-18T01:26:59.481Z","updated_at":"2025-04-10T16:05:47.088Z","avatar_url":"https://github.com/pdgendt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# COBS\n\nA Golang module for the\n[Consistent Overhead Byte Stuffing (COBS)](https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing)\nalgorithm. \n\n## Usage\n\nThis module provides both simple helper functions to Encode/Decode `[]byte` arrays and \nEncoder/Decoder structs to stream bytes to an `io.Writer` instance.\n\n### `Encode`/`Decode` functions\n\nThe helper functions will allocate buffers to hold the encoded/decoded data and return a `[]byte`\nslice or an error.\n\nThe following example encodes a string with embedded zeroes:\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/pdgendt/cobs\"\n)\n\nfunc main() {\n\tenc, _ := cobs.Encode([]byte{'H', 'e', 'l', 'l', 'o', 0x00, 'w', 'o', 'r', 'l', 'd', '!'})\n\n\tos.Stdout.write(enc)\n}\n```\n\n### `Encoder`/`Decoder` structs\n\nThe structs require an `io.Writer` instance on creation. As soon as data is available it is written,\nfor the `Encoder` this is done for each group, with a maximum of 255 bytes, for the `Decoder` every\n`byte` is written individually.\n\nThe structs implement the `io.Writer` interface to allow chaining.\n\nThe following example encodes bytes read from `os.Stdin` and writes them to `os.Stdout`:\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/pdgendt/cobs\"\n)\n\nfunc main() {\n\tenc := cobs.NewEncoder(os.Stdout)\n\n\tif _, err := io.Copy(enc, os.Stdin); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Close needs to be called to flush the last group\n\tif err := enc.Close(); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n## CLI tools\n\nThe [cmd/](cmd/) directory contains simple encode/decode command line tools that take in data\nfrom `stdin` and writes it to `stdout`.\n\nThis can be used to pipe encoded/decoded data to other processes.\n\n```shell\n$ echo \"Hello world\" | go run cmd/encode/main.go | go run cmd/decode/main.go\nHello world\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdgendt%2Fcobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdgendt%2Fcobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdgendt%2Fcobs/lists"}