{"id":16066510,"url":"https://github.com/kyrylo/netstring","last_synced_at":"2025-04-05T10:14:01.744Z","repository":{"id":43729835,"uuid":"262735433","full_name":"kyrylo/netstring","owner":"kyrylo","description":"A package for Go for formatting byte strings that use a declarative notation to indicate the size of the string","archived":false,"fork":false,"pushed_at":"2022-11-07T20:08:58.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T20:56:45.893Z","etag":null,"topics":["go","golang","library","netstring","netstrings"],"latest_commit_sha":null,"homepage":"https://cr.yp.to/proto/netstrings.txt","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/kyrylo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-10T07:34:47.000Z","updated_at":"2022-11-07T20:07:14.000Z","dependencies_parsed_at":"2023-01-21T04:47:51.582Z","dependency_job_id":null,"html_url":"https://github.com/kyrylo/netstring","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyrylo%2Fnetstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyrylo%2Fnetstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyrylo%2Fnetstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyrylo%2Fnetstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyrylo","download_url":"https://codeload.github.com/kyrylo/netstring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318746,"owners_count":20919483,"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","golang","library","netstring","netstrings"],"created_at":"2024-10-09T05:41:46.020Z","updated_at":"2025-04-05T10:14:01.723Z","avatar_url":"https://github.com/kyrylo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Netstring\n\n[![.github/workflows/test.yml](https://github.com/kyrylo/netstring/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/kyrylo/netstring/actions/workflows/test.yml)\n\n- [Netstring README][netstring-github]\n- [pkg.go.dev documentation][docs]\n\n## Introduction\n\n_Netstring_ is a library for packing and parsing [netstrings][netstring],\nself-delimiting encoding of strings. The library is extremely simple and well-tested.\n\nNetstrings may be used as a basic building block for reliable network protocols.\nMost high-level protocols, in effect, transmit a sequence of strings; those\nstrings may be encoded as netstrings and then concatenated into a sequence of\ncharacters, which in turn may be transmitted over a reliable stream protocol\nsuch as TCP.\n\n## Installation\n\n### Go modules\n\nNetstring can be installed like any other Go package that supports [Go\nmodules][go-mod].\n\n#### Installing in an existing project\n\nJust `go get` the library:\n\n```sh\ngo get github.com/kyrylo/netstring\n```\n\n## Example\n\n### Parsing a netstring into a byte string\n\n```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/kyrylo/netstring\"\n)\n\nfunc main() {\n\t// The netstring is \"8:sunshine,\"\n\tnetstr := []byte{\n\t\t0x38, 0x3a, 0x73, 0x75, 0x6e, 0x73, 0x68, 0x69, 0x6e, 0x65, 0x2c,\n\t}\n\n\t// Create a reader.\n\tbuf := bufio.NewReader(bytes.NewReader(netstr))\n\n\t// Parse the \"8:sunshine,\" into \"sunshine\".\n\tstr, err := netstring.Parse(buf)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Output: \"sunshine\"\n\tfmt.Printf(\"Input netstring: %s\\n\", netstr)\n\tfmt.Printf(\"  Parsed string: %s\\n\", str)\n}\n```\n\n### Packing a byte string into a netstring\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/kyrylo/netstring\"\n)\n\nfunc main() {\n\ts := []byte(\"sunshine\")\n\tnetstr, err := netstring.Pack(s)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// netstr is \"8:sunshine,\"\n\t// bytes: [0x38, 0x3a, 0x73, 0x75, 0x6e, 0x73, 0x68, 0x69, 0x6e, 0x65, 0x2c]\n\tfmt.Printf(\"    Input string: %s\\n\", s)\n\tfmt.Printf(\"Output netstring: %s\\n\", netstr)\n}\n```\n\n## Supported Go versions\n\nThe library supports Go v1.17+. The CI file would be the best source of truth\nbecause it contains all Go versions that are tested against.\n\n## Contact\n\nIn case you have a problem, question or a bug report, feel free to:\n\n- [file an issue][issues]\n- [tweet at me][twitter]\n\n## License\n\nThe project uses the MIT License. See LICENSE.md for details.\n\n[netstring-github]: https://github.com/kyrylo/netstring\n[netstring]: https://cr.yp.to/proto/netstrings.txt\n[semver2]: http://semver.org/spec/v2.0.0.html\n[go-mod]: https://github.com/golang/go/wiki/Modules\n[issues]: https://github.com/kyrylo/netstring/issues\n[twitter]: https://twitter.com/kyrylosilin\n[docs]: https://pkg.go.dev/github.com/kyrylo/netstring\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyrylo%2Fnetstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyrylo%2Fnetstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyrylo%2Fnetstring/lists"}