{"id":22540641,"url":"https://github.com/dolmen-go/contextio","last_synced_at":"2025-04-09T21:45:37.193Z","repository":{"id":48171442,"uuid":"156411683","full_name":"dolmen-go/contextio","owner":"dolmen-go","description":"Context-aware I/O streams (Writer, Reader) for Go","archived":false,"fork":false,"pushed_at":"2023-04-21T14:53:21.000Z","size":15,"stargazers_count":53,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T23:42:53.557Z","etag":null,"topics":["context","go","golang-module","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/dolmen-go/contextio","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dolmen-go.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":"2018-11-06T16:16:07.000Z","updated_at":"2025-03-04T19:26:19.000Z","dependencies_parsed_at":"2024-06-18T22:43:10.732Z","dependency_job_id":"cdc68727-180f-4c1f-a8f7-bed6f6b899c0","html_url":"https://github.com/dolmen-go/contextio","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/dolmen-go%2Fcontextio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen-go%2Fcontextio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen-go%2Fcontextio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dolmen-go%2Fcontextio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dolmen-go","download_url":"https://codeload.github.com/dolmen-go/contextio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119439,"owners_count":21050754,"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":["context","go","golang-module","hacktoberfest"],"created_at":"2024-12-07T12:11:48.601Z","updated_at":"2025-04-09T21:45:37.171Z","avatar_url":"https://github.com/dolmen-go.png","language":"Go","readme":"# contextio - Context-aware I/O streams for Go\n\n[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/dolmen-go/contextio)\n[![stability: stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)\n[![codecov](https://codecov.io/gh/dolmen-go/contextio/branch/master/graph/badge.svg)](https://codecov.io/gh/dolmen-go/contextio)\n[![Travis-CI](https://api.travis-ci.org/dolmen-go/contextio.svg?branch=master)](https://travis-ci.org/dolmen-go/contextio)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dolmen-go/contextio)](https://goreportcard.com/report/github.com/dolmen-go/contextio)\n\nAuthor: [@dolmen](https://github.com/dolmen)  (Olivier Mengué).\n\n# Example\n\n`go test -run ExampleWriter`\n\n```go\nfunc main() {\n\t// interrupt context after 500ms\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\t// interrupt context with SIGTERM (CTRL+C)\n\tsigs := make(chan os.Signal, 1)\n\tsignal.Notify(sigs, os.Interrupt)\n\tgo func() {\n\t\t\u003c-sigs\n\t\tcancel()\n\t}()\n\n\tf, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer f.Close()\n\n\t// Writer that fails when context is canceled\n\tout := contextio.NewWriter(ctx, f)\n\n\t// Infinite loop. Will only be interrupted once write fails.\n\tfor {\n\t\tif _, err := out.Write([]byte{'a', 'b', 'c'}); err != nil {\n\t\t\tfmt.Println(\"Err:\", err)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfmt.Println(\"Closing.\")\n}\n```\n\n# See Also\n\n* [github.com/jbenet/go-context/io](https://godoc.org/github.com/jbenet/go-context/io) Context-aware reader and writer\n* [github.com/northbright/ctx/ctxcopy](https://godoc.org/github.com/northbright/ctx/ctxcopy) Context-aware io.Copy\n* [gitlab.com/streamy/concon](https://godoc.org/gitlab.com/streamy/concon) Context-aware net.Conn\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolmen-go%2Fcontextio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdolmen-go%2Fcontextio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolmen-go%2Fcontextio/lists"}