{"id":18401389,"url":"https://github.com/dozyio/go-lpstream","last_synced_at":"2025-10-05T18:12:01.479Z","repository":{"id":255339559,"uuid":"849286154","full_name":"dozyio/go-lpstream","owner":"dozyio","description":"A length prefixed varint stream ReadWriter for Go","archived":false,"fork":false,"pushed_at":"2024-08-29T11:43:12.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T03:32:58.078Z","etag":null,"topics":["go","length-prefixed","readwriter","stream","varint"],"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/dozyio.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-08-29T10:19:41.000Z","updated_at":"2024-08-29T11:42:59.000Z","dependencies_parsed_at":"2024-08-29T11:44:13.583Z","dependency_job_id":"93870d2e-c1cb-4caf-8f1d-3ff5ea282db8","html_url":"https://github.com/dozyio/go-lpstream","commit_stats":null,"previous_names":["dozyio/go-lpstream"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozyio%2Fgo-lpstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozyio%2Fgo-lpstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozyio%2Fgo-lpstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozyio%2Fgo-lpstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dozyio","download_url":"https://codeload.github.com/dozyio/go-lpstream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248605095,"owners_count":21132106,"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":["go","length-prefixed","readwriter","stream","varint"],"created_at":"2024-11-06T02:38:41.801Z","updated_at":"2025-10-05T18:11:56.456Z","avatar_url":"https://github.com/dozyio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go LPStream\n\nA length prefixed varint stream ReadWriter for Go.\n\n## Example length prefixed network.Stream handler\n\n```go\nfunc handler(s network.Stream) {\n    lps := lpstream.New(s)\n\n    buf, err := lps.Read()\n    if err != nil {\n        fmt.Printf(\"Error reading from stream: %v\\n\", err)\n        s.Reset()\n        return\n    }\n\n    // echo the received buf\n    err = lps.Write(buf)\n    if err != nil {\n        fmt.Printf(\"Error writing to stream: %v\\n\", err)\n        s.Reset()\n        return\n    }\n\n    s.Close()\n}\n```\n\n## Example with context\n\n```go\nfunc handler(s network.Stream) {\n    lps := lpstream.New(s)\n\n    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n    defer cancel()\n\n    buf, err := lps.Read(lpstream.AbortOptions{Context: ctx})\n    if err != nil {\n        fmt.Printf(\"Error reading from stream: %v\\n\", err)\n        s.Reset()\n        return\n    }\n\n    // echo the received buf\n    err = lps.Write(buf, lpstream.AbortOptions{Context: ctx})\n    if err != nil {\n        fmt.Printf(\"Error writing to stream: %v\\n\", err)\n        s.Reset()\n        return\n    }\n\n    s.Close()\n}\n```\n\nSee tests for examples of writing multiple buffers with WriteV and setting the max length.\n\n## Tests\n\n### Unit tests\n```sh\ngo test -v ./...\n```\n\n### Benchmark Tests\n```sh\ngo test -bench=^Benchmark -benchmem ./...\n```\n\n### Fuzz Tests\n```sh\n./fuzz.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdozyio%2Fgo-lpstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdozyio%2Fgo-lpstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdozyio%2Fgo-lpstream/lists"}