{"id":19288521,"url":"https://github.com/samber/go-metered-io","last_synced_at":"2025-04-22T04:33:36.956Z","repository":{"id":187743116,"uuid":"677494344","full_name":"samber/go-metered-io","owner":"samber","description":"📐 A drop-in replacement to io.Reader and io.Writer with the total number of bytes transfered.","archived":false,"fork":false,"pushed_at":"2024-11-09T18:03:33.000Z","size":34,"stargazers_count":24,"open_issues_count":7,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-09T19:17:47.206Z","etag":null,"topics":["buffer","bytes","go","io","measure","metric","monitoring","reader","rune","stream","string","writer"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/samber/go-metered-io","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/samber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["samber"]}},"created_at":"2023-08-11T18:03:35.000Z","updated_at":"2024-11-09T18:02:23.000Z","dependencies_parsed_at":"2024-11-09T19:17:52.488Z","dependency_job_id":"6938e2a3-3983-4f79-88b4-7c0ceac30db0","html_url":"https://github.com/samber/go-metered-io","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"f3250238d539bbb89ace7601aa51e63ea9edd50c"},"previous_names":["samber/go-metered-io"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fgo-metered-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fgo-metered-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fgo-metered-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samber%2Fgo-metered-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samber","download_url":"https://codeload.github.com/samber/go-metered-io/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223888365,"owners_count":17220083,"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":["buffer","bytes","go","io","measure","metric","monitoring","reader","rune","stream","string","writer"],"created_at":"2024-11-09T22:09:15.611Z","updated_at":"2024-11-09T22:09:16.448Z","avatar_url":"https://github.com/samber.png","language":"Go","funding_links":["https://github.com/sponsors/samber"],"categories":[],"sub_categories":[],"readme":"\n# Metered io.Reader and io.Writer\n\n[![tag](https://img.shields.io/github/tag/samber/go-metered-io.svg)](https://github.com/samber/go-metered-io/releases)\n![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.16.0-%23007d9c)\n[![GoDoc](https://godoc.org/github.com/samber/go-metered-io?status.svg)](https://pkg.go.dev/github.com/samber/go-metered-io)\n![Build Status](https://github.com/samber/go-metered-io/actions/workflows/test.yml/badge.svg)\n[![Go report](https://goreportcard.com/badge/github.com/samber/go-metered-io)](https://goreportcard.com/report/github.com/samber/go-metered-io)\n[![Coverage](https://img.shields.io/codecov/c/github/samber/go-metered-io)](https://codecov.io/gh/samber/go-metered-io)\n[![Contributors](https://img.shields.io/github/contributors/samber/go-metered-io)](https://github.com/samber/go-metered-io/graphs/contributors)\n[![License](https://img.shields.io/github/license/samber/go-metered-io)](./LICENSE)\n\nA drop-in replacement to `io.Reader` and `io.Writer` from the standard library with the total number of bytes transfered.\n\n## 🚀 Install\n\n```sh\ngo get github.com/samber/go-metered-io\n```\n\nThis library is v1 and follows SemVer strictly. No breaking changes will be made to exported APIs before v2.0.0.\n\n## 💡 Spec\n\nGoDoc: [https://pkg.go.dev/github.com/samber/go-metered-io](https://pkg.go.dev/github.com/samber/go-metered-io)\n\nByte:\n- metered.NewReader\n- metered.NewWriter\n- metered.NewReadCloser\n- metered.NewWriteCloser\n- metered.NewReadWriter\n\nString:\n- metered.NewStringWriter\n\nRune:\n- metered.NewRuneReader\n\n## Examples\n\n### Metered reader\n\n```go\nimport \"github.com/samber/go-metered-io\"\n\nr := metered.NewReader(strings.NewReader(\"Lorem ipsum dolor sit amet...\"))\n\nfor {\n    buff := make([]byte, 10)\n\n    _, err := r.Read(buff)\n    if err != nil {\n        break\n    }\n}\n\nfmt.Printf(\"Total bytes: %d\", r.Rx())\n```\n\n### Metered writer\n\n```go\nimport \"github.com/samber/go-metered-io\"\n\nvar buf bytes.Buffer\nw := metered.NewWriter(\u0026buf)\n\nfor i := 0 ; i \u003c 10 ; i++ {\n    _, err := w.Write(\"Hello world\\n\")\n    if err != nil {\n        break\n    }\n}\n\nfmt.Printf(\"Total bytes: %d\", w.Tx())\n```\n\n## 🤝 Contributing\n\n- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))\n- Fork the [project](https://github.com/samber/go-metered-io)\n- Fix [open issues](https://github.com/samber/go-metered-io/issues) or request new features\n\nDon't hesitate ;)\n\n```bash\n# Install some dev dependencies\nmake tools\n\n# Run tests\nmake test\n# or\nmake watch-test\n```\n\n## 👤 Contributors\n\n![Contributors](https://contrib.rocks/image?repo=samber/go-metered-io)\n\n## 💫 Show your support\n\nGive a ⭐️ if this project helped you!\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/samber?style=for-the-badge)](https://github.com/sponsors/samber)\n\n## 📝 License\n\nCopyright © 2023 [Samuel Berthe](https://github.com/samber).\n\nThis project is [MIT](./LICENSE) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fgo-metered-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamber%2Fgo-metered-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamber%2Fgo-metered-io/lists"}