golang-context
Improve Go Context Propagation and Cancellation
Broken context propagation leaves downstream work running after requests end. This skill guides context lifecycles across Go handlers, services, and databases.
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "golang-context" from https://skillstore.io/skills/samber-golang-context.md and its manifest at https://skillstore.io/api/skills/samber-golang-context/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“golang-context”。 Review a handler that creates Background before calling its repository and payment client.
预期结果:
- The handler discards request cancellation by creating a new root context.
- Pass the request context through service, database, and HTTP client calls.
- Test that client cancellation reaches both downstream operations.
正在使用“golang-context”。 Review a repository transaction that starts with Begin but uses ExecContext for its updates.
预期结果:
- Transaction creation does not receive the caller context.
- Start the transaction with BeginTx and keep passing the caller context to statements.
- Retain rollback cleanup and test cancellation during transaction startup.
正在使用“golang-context”。 Explain why an asynchronous audit event stops when its HTTP handler returns.
预期结果:
- The goroutine inherits a request context that is canceled when the handler returns.
- WithoutCancel preserves request values while removing cancellation and deadlines.
- Add a finite timeout and shutdown ownership; detaching cancellation alone does not guarantee delivery.
安全审计
中风险All 49 static findings are false positives caused by Markdown formatting, Go identifiers, metadata, or illustrative evaluation fixtures. No evidence found of prompt injection, credential theft, system reconnaissance, or unauthorized command execution. One semantic risk remains: the background audit example removes cancellation and deadlines without bounding its goroutine lifetime.
已确认安全问题 (1)
风险因素
⚙️ 外部命令 (25)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/samber-golang-context/audits/1?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/samber-golang-context?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/samber-golang-context?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/samber-golang-context/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/samber-golang-context.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
samber. (2026). golang-context security audit report (audit version 1) [Author version 1.3.1]. Skillstore. https://skillstore.io/skills/samber-golang-context/audits/1BibTeX 引用
@techreport{samber-samber-golang-context-2026,
author = {samber},
title = {golang-context security audit report (audit version 1)},
institution = {Skillstore},
year = {2026},
number = {1},
url = {https://skillstore.io/skills/samber-golang-context/audits/1},
note = {Author version 1.3.1}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "golang-context security audit report (audit version 1)"
version: "1.3.1"
type: report
authors:
- name: "samber"
date-released: "2026-10-15"
url: "https://skillstore.io/skills/samber-golang-context/audits/1"
identifiers:
- type: other
value: "skillstore:samber-golang-context:audit:1"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 中你能构建什么
Review Request Cancellation
Find context propagation breaks between handlers, services, SQL queries, and downstream HTTP requests.
Investigate Work That Outlives Requests
Review cancellation ownership, timeout cleanup, and background goroutines that continue after client disconnection.
Standardize Request Metadata
Design typed context accessors and trace propagation conventions without hiding business inputs or infrastructure dependencies.
试试这些提示
Explain when to use Background, TODO, and r.Context in Go. Review this function: [function].
Review this handler, service, and repository for broken context propagation: [code]. Identify missing context-aware calls and cancellation cleanup.
Review this service flow: [code]. Propose nested timeout budgets and typed request metadata accessors while keeping dependencies explicit.
Review this asynchronous audit flow: [code]. Preserve trace values with WithoutCancel, add a finite timeout, and assess shutdown ownership and concurrency limits.
最佳实践
- Pass the caller context as the first parameter and use context-aware downstream APIs.
- Release derived contexts on every path unless cancellation ownership is explicitly transferred.
- Use typed metadata keys and give detached work an explicit timeout and lifecycle owner.
避免
- Creating a new Background context inside a request call chain.
- Using context values to hide database connections, configuration, or required business arguments.
- Launching detached goroutines without lifetime limits or shutdown coordination.
常见问题
Which AI tools does this skill support?
Which Go version do the newer context examples require?
Does this skill automatically detect every context bug?
What belongs in context values?
Can a child timeout extend its parent deadline?
Does WithoutCancel guarantee background audit delivery?
开发者详情
作者
samber许可证
MIT
作者版本
v1.3.1
Skillstore 修订
r1
引用
e8578ae623cd20ef61db8894d3441416b52a9dad
维护新鲜度
2026/10/15
使用量
0 次下载 · 0 次浏览
文件结构