go-concurrency-patterns

Provides Go programming patterns for building concurrent applications with goroutines and channels.

10|3|Updated Apr 3, 2012
One-click install
npx skills add https://github.com/liuerfire/dotfiles --skill go-concurrency-patterns-liuerfire
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-concurrency-patterns
Source: https://github.com/liuerfire/dotfiles/tree/main/agentic/skills/go-concurrency-patterns
Command: npx skills add https://github.com/liuerfire/dotfiles --skill go-concurrency-patterns-liuerfire

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides robust solutions for building efficient and scalable concurrent applications in Go, addressing common challenges in managing goroutines, channels, and synchronization.

Core Features & Use Cases

  • Concurrency Primitives: Utilizes goroutines, channels, select, sync primitives, and context for effective concurrency management.
  • Pattern Implementation: Offers patterns for worker pools, fan-out/fan-in pipelines, rate limiting, graceful shutdown, and error handling with cancellation.
  • Use Case: When developing a web service that needs to handle many requests concurrently, this skill can be used to implement a worker pool to process incoming tasks efficiently and a graceful shutdown mechanism to ensure all operations complete before the service stops.

Quick Start

Use the go-concurrency-patterns skill to implement a worker pool for processing jobs concurrently.

Frequently Asked Questions about go-concurrency-patterns

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

FAQPage Schema
How do I implement a worker pool in Go to process jobs concurrently?

To implement a worker pool in Go, you use goroutines to process jobs concurrently and channels to distribute and collect the tasks. This pattern efficiently manages parallelism by limiting the number of active goroutines processing incoming requests.

What is the best way to handle graceful shutdown in a concurrent Go application?

Graceful shutdown in a concurrent Go application is best handled using context management and sync primitives. This ensures all in-flight operations complete successfully before the service stops, preventing data loss during termination.

How do I build a fan-out fan-in pipeline using Go channels?

Building a fan-out fan-in pipeline in Go involves distributing work across multiple goroutines and aggregating the results into a single channel. This pattern maximizes throughput for concurrent stages of data processing.

Why does my Go application have race conditions and how do I debug them?

Race conditions in Go occur when multiple goroutines access shared data concurrently without proper synchronization. You can debug these race conditions using sync primitives and careful channel management to protect shared state.

Can I use Go concurrency patterns for rate limiting and error handling with cancellation?

Yes, Go concurrency patterns support rate limiting to control resource usage and error handling with cancellation using context. These patterns allow you to manage concurrent task lifecycles and propagate errors effectively across goroutines.