{"id":19806001,"url":"https://github.com/cycloidio/mxwriter","last_synced_at":"2025-02-28T12:19:44.171Z","repository":{"id":47085372,"uuid":"336434924","full_name":"cycloidio/mxwriter","owner":"cycloidio","description":"MXWriter is a small library that emulates a Multiplexer and Demultiplexer for io.Write.","archived":false,"fork":false,"pushed_at":"2021-09-14T08:39:43.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-11T06:13:21.848Z","etag":null,"topics":["demultiplexer","demux","go","golang","io","multiplexer","mux","wirte","writer"],"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/cycloidio.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":"2021-02-06T02:05:44.000Z","updated_at":"2024-01-12T21:12:06.000Z","dependencies_parsed_at":"2022-08-23T12:31:06.352Z","dependency_job_id":null,"html_url":"https://github.com/cycloidio/mxwriter","commit_stats":null,"previous_names":["cycloidio/writer"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fmxwriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fmxwriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fmxwriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cycloidio%2Fmxwriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cycloidio","download_url":"https://codeload.github.com/cycloidio/mxwriter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241150243,"owners_count":19918334,"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":["demultiplexer","demux","go","golang","io","multiplexer","mux","wirte","writer"],"created_at":"2024-11-12T09:06:09.105Z","updated_at":"2025-02-28T12:19:44.142Z","avatar_url":"https://github.com/cycloidio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MXWriter\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/cycloidio/mxwriter)](https://pkg.go.dev/github.com/cycloidio/mxwriter)\n\nMXWriter is a small library that emulates a **Multiplexer** and **Demultiplexer** for `io.Write`.\n\nThe main goal is to be able to use one `io.Writer` to write different content and then\nbe able to read that content separately or all together without having to worry on the\norder of the writes or how many different ones you have.\n\nThe Use Case is when you only have 1 `io.Writer` and want to write different things\n(files for example) into it so then you can read them aggregated.\n\n## Install\n\n```\n$\u003e go get github.com/cycloidio/mxwriter\n```\n\n## Usage\n\nFirst initialize the `mxwriter.NewMux()` and then you can use it as a normal `io.ReadWriter`. When\nyou are writing information to it you have to do it in an specific way `\u003clength-key\u003e;\u003ckey\u003e\u003ccontent\u003e`.\nYou can also use a helper `mxwriter.Write(w io.Writer, key string, content []byte)` which will directly\nwrite in the specific format.\n\nExample:\n\n```go\npackage example\n\nimport (\n\t\"io/ioutil\"\n\n\t\"github.com/cycloidio/mxwriter\"\n)\n\nfunc main() {\n  // Initializes the Mux\n  m := mxwriter.NewMux()\n\n  // Initializes the Demux\n  dm, err := mxwriter.NewDemux(m)\n  if err != nil {\n    log.Fatal(err)\n  }\n\n  // Write to the Mux\n  m.Write([]byte(\"5;test1content\"))\n  m.Write([]byte(\"5;test2content\"))\n  m.Write([]byte(\"4;testcontent\"))\n\n  // Write to the Mux with the helper\n  mxwriter.Write(m, \"test\", []byte(\"content\"))\n\n  // If you want to read all of it\n  b, _ := ioutil.ReadAll(m)\n\n  // If you want to read an specific key\n  b, _ := ioutil.ReadAll(dm.Read(\"test1\"))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fmxwriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycloidio%2Fmxwriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycloidio%2Fmxwriter/lists"}