go-concurrency-patterns
यह क्या करती है
यह टूल आपको Go प्रोग्राम में एक साथ कई काम करने के उन्नत तरीके समझने और इस्तेमाल करने में मदद करता है। यह सिखाता है कि 'goroutines' (छोटे tasks जो साथ-साथ चलते हैं) और 'channels' (इन tasks के बीच संवाद की लाइनें) कैसे इस्तेमाल करें।
कब इस्तेमाल करें
- ✓जब Go प्रोग्राम बनाना हो जिसे एक साथ कई काम करने हों।
- ✓जब tasks को मिलकर कुशलता से काम करवाना हो (जैसे 'worker pools' में)।
- ✓जब आपका प्रोग्राम crash हो रहा हो या concurrency errors आ रहे हों, और उनका कारण समझना हो।
Skill का लिंक
https://github.com/wshobson/agents/blob/main/plugins/systems-programming/skills/go-concurrency-patterns/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं अपने Go प्रोग्राम के दो हिस्सों को एक साथ कैसे चला सकता हूँ और उनके बीच सुरक्षित तरीके से जानकारी कैसे भेज सकता हूँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह Go में concurrency के बुनियादी हिस्से, जैसे 'goroutines' और 'channels', समझाता है, और संवाद व synchronization के लिए उनके उदाहरण दिखाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Go Concurrency Patterns
Production patterns for Go concurrency including goroutines, channels, synchronization primitives, and context management.
When to Use This Skill
- Building concurrent Go applications
- Implementing worker pools and pipelines
- Managing goroutine lifecycles
- Using channels for communication
- Debugging race conditions
- Implementing graceful shutdown
Core Concepts
1. Go Concurrency Primitives
| Primitive | Purpose |
|---|---|
goroutine |
Lightweight concurrent execution |
channel |
Communication between goroutines |
select |
Multiplex channel operations |
sync.Mutex |
Mutual exclusion |
sync.WaitGroup |
Wait for goroutines to complete |
context.Context |
Cancellation and deadlines |
2. Go Concurrency Mantra
Don't communicate by sharing memory;
share memory by communicating.
Quick Start
package main
import (
"context"
"fmt"
"sync"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
results := make(chan string, 10)
var wg sync.WaitGroup
// Spawn workers
for i := 0; i < 3; i++ {
wg.Add(1)
go worker(ctx, i, results, &wg)
}
// Close results when done
go func() {
wg.Wait()
close(results)
}()
// Collect results
for result := range results {
fmt.Println(result)
}
}
func worker(ctx context.Context, id int, results chan<- string, wg *sync.WaitGroup) {
defer wg.Done()
select {
case <-ctx.Done():
return
case results <- fmt.Sprintf("Worker %d done", id):
}
}
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
Do's
- Use context - For cancellation and deadlines
- Close channels - From sender side only
- Use errgroup - For concurrent operations with errors
- Buffer channels - When you know the count
- Prefer channels - Over mutexes when possible
Don'ts
- Don't leak goroutines - Always have exit path
- Don't close from receiver - Causes panic
- Don't use shared memory - Unless necessary
- Don't ignore context cancellation - Check ctx.Done()
- Don't use time.Sleep for sync - Use proper primitives
अक्सर पूछे जाने वाले सवाल
'goroutine' क्या है?
यह एक function की तरह है जो आपके प्रोग्राम के दूसरे हिस्सों के साथ, बिना उनमें दखल दिए, एक साथ चल सकता है।
'channels' किसलिए होते हैं?
ये पाइप की तरह होते हैं, जिनके ज़रिए 'goroutines' एक-दूसरे को सुरक्षित तरीके से संदेश भेज और पा सकते हैं।
'Don't communicate by sharing memory; share memory by communicating' का क्या मतलब है?
यह सलाह है कि प्रोग्राम के कई हिस्से एक ही समय पर एक ही data को access न करें (इससे errors हो सकते हैं)। इसके बजाय 'channels' से data एक-दूसरे तक पहुँचाएँ।
जानकारी
लेखक का मूल विवरण
Master Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.
repo: wshobson/agents
लोकप्रियता
- GitHub स्टार
- 41k
- रैंकिंग में स्थान
- #6798
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
screen-reader-testing
41kआपके एजेंट को screen readers का इस्तेमाल करके वेबसाइटों की जांच करने देता है, ताकि यह पक्का हो सके कि वे accessible हैं।
wcag-audit-patterns
41kआपके एजेंट को वेबसाइटों का accessibility audit करने और WCAG guidelines के हिसाब से समस्याएं ठीक करने में मदद करता है।
multi-reviewer-patterns
41kआपके एजेंट को कई code reviews को एक साथ चलाने देता है। यह एक जैसे findings हटाता है और सारी रिपोर्ट को एक जगह जोड़ता है।
parallel-debugging
41kआपके एजेंट को parallel जांच के साथ जटिल समस्याओं को debug करने और root cause analysis में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।