{"id":13786675,"url":"https://github.com/zerosnake0/goctx","last_synced_at":"2026-01-27T13:41:16.764Z","repository":{"id":57555758,"uuid":"312830880","full_name":"zerosnake0/goctx","owner":"zerosnake0","description":"Get your context value faster","archived":false,"fork":false,"pushed_at":"2020-11-24T14:42:11.000Z","size":11,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T22:39:03.089Z","etag":null,"topics":["context","golang"],"latest_commit_sha":null,"homepage":"","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/zerosnake0.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":"2020-11-14T14:16:09.000Z","updated_at":"2024-12-01T18:15:37.000Z","dependencies_parsed_at":"2022-09-14T11:00:49.662Z","dependency_job_id":null,"html_url":"https://github.com/zerosnake0/goctx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zerosnake0/goctx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fgoctx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fgoctx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fgoctx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fgoctx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerosnake0","download_url":"https://codeload.github.com/zerosnake0/goctx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerosnake0%2Fgoctx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","golang"],"created_at":"2024-08-03T19:01:27.915Z","updated_at":"2026-01-27T13:41:16.750Z","avatar_url":"https://github.com/zerosnake0.png","language":"Go","funding_links":[],"categories":["Utilities","公用事业公司","Utility","工具库","工具库`可以提升效率的通用代码库和工具`"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","Fail injection","查询语","HTTP Clients"],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/zerosnake0/goctx)](https://goreportcard.com/report/github.com/zerosnake0/goctx)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/zerosnake0/goctx)](https://pkg.go.dev/github.com/zerosnake0/goctx)\n[![Github Workflow](https://github.com/zerosnake0/goctx/workflows/Test/badge.svg)](https://github.com/zerosnake0/goctx/actions?query=workflow%3ATest)\n[![Build Status](https://travis-ci.org/zerosnake0/goctx.svg?branch=main)](https://travis-ci.org/zerosnake0/goctx)\n[![codecov](https://codecov.io/gh/zerosnake0/goctx/branch/main/graph/badge.svg)](https://codecov.io/gh/zerosnake0/goctx)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\n# goctx\n\nGet your context value faster\n\n## How to use\n\nReplace\n\n```go\nv := ctx.Value(key)\n```\n\nWith\n\n```go\nv := goctx.Value(ctx, key)\n```\n\n## Benchmark\n\nThere will be little difference when there is only 1~2 `context.WithXXX` calls\n\nWith 5 `context.WithXXX` calls\n\n|  |  |  |\n| --- | --- | --- |\n| BenchmarkValue/5/non_parallel/std-8      | 35313684  | 34.2 ns/op |\n| BenchmarkValue/5/non_parallel/goctx-8    | 42801348  | 30.0 ns/op |\n| BenchmarkValue/5/non_parallel/pure_map-8 | 16655377  | 72.8 ns/op |\n| BenchmarkValue/5/parallel/std-8          | 168420460 | 7.09 ns/op |\n| BenchmarkValue/5/parallel/goctx-8        | 185695462 | 6.35 ns/op |\n| BenchmarkValue/5/parallel/pure_map-8     | 67944997  | 17.6 ns/op |\n\nWith 20 `context.WithXXX` calls\n\n|  |  |  |\n| --- | --- | --- |\n| BenchmarkValue/20/non_parallel/std-8      |  7137338 |  168 ns/op |\n| BenchmarkValue/20/non_parallel/goctx-8    | 14623730 | 81.4 ns/op |\n| BenchmarkValue/20/non_parallel/pure_map-8 |  5282458 |  235 ns/op |\n| BenchmarkValue/20/parallel/std-8          | 42826857 | 27.9 ns/op |\n| BenchmarkValue/20/parallel/goctx-8        | 79149823 | 15.1 ns/op |\n| BenchmarkValue/20/parallel/pure_map-8     | 22206717 | 53.8 ns/op |\n\nAs we can see from the benchmark test, the map implementation is slower than the\nstandard one, so it is not recommended to use `RegisterValueFunc` to register a\ncontext value function, unless you do not want to see nested stack with `Value` method\ncall (That's also the reason why `RegisterValueFunc` is kept even it is not fast)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerosnake0%2Fgoctx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerosnake0%2Fgoctx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerosnake0%2Fgoctx/lists"}