{"id":18452026,"url":"https://github.com/zenizh/go-capturer","last_synced_at":"2025-04-13T15:34:44.401Z","repository":{"id":45348694,"uuid":"113801805","full_name":"zenizh/go-capturer","owner":"zenizh","description":"Capture stdout and/or stderr in Go.","archived":false,"fork":false,"pushed_at":"2023-06-10T04:07:17.000Z","size":9,"stargazers_count":44,"open_issues_count":7,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T06:22:57.732Z","etag":null,"topics":["golang","testing"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/kami-zh/go-capturer","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/zenizh.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-12-11T02:16:19.000Z","updated_at":"2024-09-11T11:02:45.000Z","dependencies_parsed_at":"2024-06-18T15:43:06.429Z","dependency_job_id":null,"html_url":"https://github.com/zenizh/go-capturer","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"52ea6c8fed04b316685a3b1a57bb8b46b406f929"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenizh%2Fgo-capturer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenizh%2Fgo-capturer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenizh%2Fgo-capturer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenizh%2Fgo-capturer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenizh","download_url":"https://codeload.github.com/zenizh/go-capturer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248736234,"owners_count":21153555,"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":["golang","testing"],"created_at":"2024-11-06T07:29:54.020Z","updated_at":"2025-04-13T15:34:44.364Z","avatar_url":"https://github.com/zenizh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-capturer\n\n[![GoDoc](https://godoc.org/github.com/kami-zh/go-capturer?status.svg)](https://godoc.org/github.com/kami-zh/go-capturer)\n[![Build Status](https://travis-ci.org/kami-zh/go-capturer.svg?branch=master)](https://travis-ci.org/kami-zh/go-capturer)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kami-zh/go-capturer)](https://goreportcard.com/report/github.com/kami-zh/go-capturer)\n\nCapture `os.Stdout` and/or `os.Stderr` in Go.\nThis package is useful for writing tests which print some outputs using `fmt` package.\n\n## Usage\n\nThis package provides `CaptureStdout()`, `CaptureStderr()` and `CaptureOutput()` functions to capture outputs.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/kami-zh/go-capturer\"\n)\n\nfunc ExampleCaptureStdout() {\n\tout := capturer.CaptureStdout(func() {\n\t\tfmt.Fprint(os.Stdout, \"foo\")\n\t})\n\n\tfmt.Println(out)\n\t// Output: foo\n}\n\nfunc ExampleCaptureStderr() {\n\tout := capturer.CaptureStderr(func() {\n\t\tfmt.Fprint(os.Stderr, \"bar\")\n\t})\n\n\tfmt.Println(out)\n\t// Output: bar\n}\n\nfunc ExampleCaptureOutput() {\n\tout := capturer.CaptureOutput(func() {\n\t\tfmt.Fprint(os.Stdout, \"foo\")\n\t\tfmt.Fprint(os.Stderr, \"bar\")\n\t})\n\n\tfmt.Println(out)\n\t// Output: foobar\n}\n```\n\n## Installation\n\n```\n$ go get github.com/kami-zh/go-capturer\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/go-capturer.\n\n## License\n\nThe package is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenizh%2Fgo-capturer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenizh%2Fgo-capturer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenizh%2Fgo-capturer/lists"}