{"id":20388246,"url":"https://github.com/libp2p/go-msgio","last_synced_at":"2025-04-04T13:13:15.624Z","repository":{"id":26944803,"uuid":"111142789","full_name":"libp2p/go-msgio","owner":"libp2p","description":"simple package to r/w length-delimited slices.","archived":false,"fork":false,"pushed_at":"2025-03-24T09:27:35.000Z","size":113,"stargazers_count":14,"open_issues_count":4,"forks_count":12,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-28T12:09:37.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jbenet/go-msgio","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libp2p.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":"2017-11-17T19:30:48.000Z","updated_at":"2025-02-16T20:01:54.000Z","dependencies_parsed_at":"2024-03-21T15:58:51.871Z","dependency_job_id":"7ad7c440-f6dd-4207-b1f1-c95964516ee1","html_url":"https://github.com/libp2p/go-msgio","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-msgio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-msgio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-msgio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fgo-msgio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libp2p","download_url":"https://codeload.github.com/libp2p/go-msgio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182401,"owners_count":20897381,"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":[],"created_at":"2024-11-15T03:08:14.871Z","updated_at":"2025-04-04T13:13:15.598Z","avatar_url":"https://github.com/libp2p.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-msgio - Message IO\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)\n[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)\n[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)\n[![codecov](https://codecov.io/gh/libp2p/go-libp2p-netutil/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-msgio)\n[![Travis CI](https://travis-ci.org/libp2p/go-libp2p-netutil.svg?branch=master)](https://travis-ci.org/libp2p/go-msgio)\n[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)\n\nThis is a simple package that helps read and write length-delimited slices. It's helpful for building wire protocols.\n\n## Usage\n\n### Reading\n\n```go\nimport \"github.com/libp2p/go-msgio\"\nrdr := ... // some reader from a wire\nmrdr := msgio.NewReader(rdr)\n\nfor {\n  msg, err := mrdr.ReadMsg()\n  if err != nil {\n    return err\n  }\n\n  doSomething(msg)\n}\n```\n\n### Writing\n\n```go\nimport \"github.com/libp2p/go-msgio\"\nwtr := genReader()\nmwtr := msgio.NewWriter(wtr)\n\nfor {\n  msg := genMessage()\n  err := mwtr.WriteMsg(msg)\n  if err != nil {\n    return err\n  }\n}\n```\n\n### Duplex\n\n```go\nimport \"github.com/libp2p/go-msgio\"\nrw := genReadWriter()\nmrw := msgio.NewReadWriter(rw)\n\nfor {\n  msg, err := mrdr.ReadMsg()\n  if err != nil {\n    return err\n  }\n\n  // echo it back :)\n  err = mwtr.WriteMsg(msg)\n  if err != nil {\n    return err\n  }\n}\n```\n\n---\n\nThe last gx published version of this module was: 0.0.6: QmcxL9MDzSU5Mj1GcWZD8CXkAFuJXjdbjotZ93o371bKSf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fgo-msgio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibp2p%2Fgo-msgio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fgo-msgio/lists"}