跳到主要内容
知仓学习社ZHICANG

go-http-client-resilience

Design, implement, test, and review resilient Go HTTP client boundaries with context propagation, layered timeouts, transport reuse, request constru…

不碰外部(只输出文字)无严重或高危命中hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少7 个文本文件,14 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Go HTTP Client Resilience

Treat HTTP as a failure-prone boundary with a finite time and resource budget.

Retry only when both the failure and the operation are safe.

Core Workflow

  1. Define operation semantics, total deadline, idempotency, and response limits.
  2. Reuse a configured client and transport; propagate context into every request.
  3. Construct URLs, headers, authentication, and bodies without secret leakage.
  4. Classify transport, timeout, status, protocol, and decode failures.
  5. Add bounded retries with jitter only for safe transient cases.
  6. Drain or close bodies correctly and bound all reads.
  7. Test with a function-backed transport and focused integration server.

Read Next

| Task | Load |

|---|---|

| Build or overhaul an HTTP client | guidelines.md, workflows/build-http-client.md |

| Configure deadlines, retries, or pagination | references/http-client-resilience/rules.md |

| Review Go patterns | references/http-client-resilience/examples.md |

| Understand failure and budget models | references/http-client-resilience/knowledge.md |

Guardrails

  • Never use an unbounded body read or an unbounded retry loop.
  • Do not retry unsafe operations without an idempotency mechanism.
  • Do not create a new transport per request.
  • Do not log authorization headers, cookies, tokens, or unreviewed bodies.
  • Close every non-nil response body, including non-2xx responses.

Source Notes

Guidance is transformed and paraphrased from Marian Montagnino,

Building Modern CLI Applications in Go (Packt, 2023), especially Chapter 6,

and Ricardo Gerardi, Powerful Command-Line Applications in Go (2021).

Streaming, transport-pool, and HTTP test guidance also incorporates transformed

material from Inanc Gumus, *Go by Example: Programmer's Guide to Idiomatic and

Testable Programs* (Manning, 2025), Chapter 7.

Body ownership and client-timeout guidance also incorporates transformed

material from Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning,

2022), Chapter 10.

Verify behavior against https://pkg.go.dev/net/http and current API-specific

rate-limit, pagination, and idempotency documentation.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。