Skip to content
Back to skills

Golang Concurrency

ASecurity

Write safe concurrent Go code with goroutines, channels, and context. Use when implementing concurrency with goroutines, channels, or context in Go.

  • 549 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 6, 2026
developmentgo

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned June 6, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill golang-concurrency --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Golang Concurrency?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Golang Concurrency
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-golang-concurrency/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-golang-concurrency)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: golang-concurrency
description: Write safe concurrent Go code with goroutines, channels, and context. Use when implementing concurrency with goroutines, channels, or context in Go.
metadata:
  triggers:
    keywords:
    - goroutine
    - go keyword
    - channel
    - mutex
    - waitgroup
    - context
    - errgroup
    - race condition
---
# Golang Concurrency

## **Priority: P0 (CRITICAL)**

## Principles

- **Share Memory by Communicating**: Use channels instead of shared memory.
- **Context King**: Always pass `ctx` to manage cancellation/timeouts.
- **Prevent Leaks**: Never start goroutine without knowing how it will stop.
- **Race Detection**: Always run tests with `go test -race`.

## Implementation Workflow

1. **Choose primitive** — Channels for data passing, `sync.Mutex` for simple state protection, `errgroup` for parallel tasks with error handling.
2. **Pass context** — Every goroutine that I/O or long work must accept `context.Context`.
3. **Define exit paths** — Every goroutine must clear shutdown mechanism (context cancellation, channel close, or WaitGroup).
4. **Use select for multiplexing** — Handle multiple channels or timeouts with `select`.
5. **Test with race detector** — Run `go test -race` in CI.

See [ErrGroup and concurrency patterns](references/concurrency-patterns.md) and [context timeout examples](references/context-usage.md)

## Anti-Patterns

- **No goroutine leaks**: ensure every goroutine known exit path.
- **No shared global state**: use channels or sync primitives across goroutines.
- **No bare goroutines**: use `errgroup` or `WaitGroup` for lifecycle management.

## References

- [Concurrency Patterns](references/concurrency-patterns.md)
- [Context Usage](references/context-usage.md)

Files in this skill

  • SKILL.md1.7 KB
  • evals/evals.json1.5 KB
  • references/concurrency-patterns.md1.2 KB
  • references/context-usage.md1017 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.