golang-context

Implement idiomatic Go context.Context propagation across HTTP handlers and concurrent operations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-context-nrmnqdds
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-context
Source: https://github.com/nrmnqdds/gomaluum/tree/main/.agents/skills/golang-context
Command: npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-context-nrmnqdds

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go developers often misuse context.Context, leading to improper cancellation, timeouts and tracing across service boundaries. This skill teaches idiomatic usage across HTTP handlers, service calls, and concurrent workers.

Core Features & Use Cases

  • Idiomatic propagation of ctx through HTTP handlers, services, and worker routines.
  • Best practices for cancellation and deadlines (WithCancel, WithTimeout, WithDeadline) and safe use of context values.
  • Cross-service tracing and value propagation using unexported context keys.

Quick Start

Create a minimal Go HTTP server that demonstrates correct context propagation and cancellation across handlers and downstream calls.

Frequently Asked Questions about golang-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I propagate context through HTTP handlers and downstream service calls in Go?

Context propagation in Go requires passing context.Context as the first parameter through HTTP handlers and service calls. This skill enforces proper propagation across API boundaries and data stores to maintain cancellation and tracing chains.

What's the best way to handle timeouts and cancellation in concurrent Go workers?

Use context.WithCancel, context.WithTimeout, or context.WithDeadline to manage cancellation in concurrent Go workers. This skill demonstrates correct cancellation semantics for background tasks, including context.WithoutCancel for long-running operations.

Why should I use unexported keys for context values in Go?

Unexported keys for context values prevent collisions across packages in Go. This skill applies best practices for safe context value usage and cross-service tracing by enforcing unexported key types within API boundaries.

How does context.WithoutCancel work for background tasks in Go?

context.WithoutCancel allows long-running background tasks in Go to continue executing when the parent context is cancelled. This skill demonstrates using it to separate request-scoped operations from background workers correctly.

When do I need context deadlines instead of timeouts in Go services?

Context deadlines are needed when targeting a specific point in time, while timeouts define a duration in Go. This skill applies context.WithDeadline and context.WithTimeout to enforce proper cancellation semantics across service boundaries.