{"id":23263157,"url":"https://github.com/knwoop/dcontext","last_synced_at":"2025-04-06T06:21:07.990Z","repository":{"id":57644740,"uuid":"440353214","full_name":"knwoop/dcontext","owner":"knwoop","description":"Copy context.Context without setting timeout in one","archived":false,"fork":false,"pushed_at":"2022-05-24T01:00:36.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T23:40:25.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/knwoop.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-12-21T01:20:07.000Z","updated_at":"2023-03-05T07:54:18.000Z","dependencies_parsed_at":"2022-08-30T08:11:35.710Z","dependency_job_id":null,"html_url":"https://github.com/knwoop/dcontext","commit_stats":null,"previous_names":["knwoop/xcontext"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knwoop%2Fdcontext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knwoop%2Fdcontext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knwoop%2Fdcontext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knwoop%2Fdcontext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knwoop","download_url":"https://codeload.github.com/knwoop/dcontext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441872,"owners_count":20939373,"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":[],"created_at":"2024-12-19T14:15:01.370Z","updated_at":"2025-04-06T06:21:07.975Z","avatar_url":"https://github.com/knwoop.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dcontext\nCopy context.Context without setting timeout\n\n## Set up\n```bash\n$ go get -u github.com/knwoop/dcontext\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n  \n\t\"github.com/knwoop/dcontext\"\n)\n\nfunc main() {\n\tparentCtx := context.Background()\n\tparentCtx = context.WithValue(parentCtx, \"trace-id\", \"trace123\")\n\n\tctx, cancel := context.WithCancel(parentCtx)\n\n\t// detatch context\n\tdtx := dcontext.Detach(ctx)\n\n\t// Cancel context\n\tcancel()\n\n\tfmt.Println(\"dtx.Err():\", dtx.Err())\n\tfmt.Println(`dtx.Value(\"trace-id\"):`, dtx.Value(\"trace-id\"))\n\n\t// Create a child context with a deadline.\n\tttx, cancel := context.WithTimeout(dtx, time.Millisecond)\n\tcancel()\n\tdeadline, ok := ttx.Deadline()\n\tfmt.Println(\"ttx.Deadline():\", deadline, ok)\n\tfmt.Println(\"ttx.Err():\", ttx.Err())\n\tfmt.Println(`ttx.Value(\"trace-id\"):`, ttx.Value(\"trace-id\"))\n}\n```\n\n## Reference\nhttps://zenn.dev/knwoop/articles/dd93fffb48775b\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknwoop%2Fdcontext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknwoop%2Fdcontext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknwoop%2Fdcontext/lists"}