go-concurrency-patterns
تعلم أنماط التزامن في Go للإنتاج
تحديد وتصحيح أخطاء كود Go المتزامن صعب. توفر هذه المهارة أنماطًا مثبتة وأمثلة وأفضل الممارسات يمكنك التكيف معها بسرعة.
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "go-concurrency-patterns". Suggest a pattern for processing many jobs with cancellation.
النتيجة المتوقعة:
- Use a worker pool with a buffered jobs channel
- Pass a context to stop workers on cancel
- Close results channel after all workers finish
- Add errgroup when you need early failure on error
استخدام "go-concurrency-patterns". How do I run multiple functions in parallel and wait for all?
النتيجة المتوقعة:
- Use sync.WaitGroup to wait for goroutines
- Add each goroutine with wg.Add(1) before spawning
- Call wg.Done() in each goroutine defer
- Block with wg.Wait() after starting all goroutines
استخدام "go-concurrency-patterns". What happens if I close a channel from the receiver side?
النتيجة المتوقعة:
- It causes a panic
- Only close channels from the sender side
- Or use a separate goroutine dedicated to closing
- Check if channel is open before sending
التدقيق الأمني
آمنAll 58 static findings are FALSE POSITIVES. The scanner matched substrings without semantic context: 'C2' from 'close()', 'weak crypto' from 'WaitGroup', 'dynamic import' from Go import statements, 'backtick execution' from markdown code formatting, and 'path traversal' from code comments. This is a pure documentation skill containing only markdown and JSON files with Go code examples. No executable code, no network calls beyond documentation links, no filesystem access beyond its own files.
عوامل الخطر
🌐 الوصول إلى الشبكة (1)
⚡ يحتوي على سكربتات (1)
⚙️ الأوامر الخارجية (1)
درجة الجودة
ماذا يمكنك بناءه
تصميم خدمات متزامنة
اختر أنماط worker وpipeline وإلغاء الخدمات للإنتاج.
تخطيط إيقاف التشغيل الآمن
أضف معالجة إيقاف آمن وtimeout للعمليات طويلة المدى.
فهم أساسيات التزامن
تعلم goroutines والقنوات والتزامن مع أمثلة واضحة.
جرّب هذه الموجهات
اشرح goroutines والقنوات مع مثال صغير للمبتدئين.
وفر نمط worker pool في Go مع إلغاء السياق وقناة jobs وقناة results.
اعرض نمط إيقاف التشغيل الآمن باستخدام السياق وإشارات نظام التشغيل، مع شرح موجز.
قارن أنماط تحديد semaphore وerrgroup واختر واحدة لمهام جلب API.
أفضل الممارسات
- استخدم السياق للإلغاء والمواعيد النهائية في جميع العمليات المتزامنة
- أغلق القنوات من جانب المرسل فقط لتجنب الـ panics
- تأكد من وجود مسار خروج واضح للـ goroutines وتحقق من ctx.Done بانتظام
تجنب
- استخدام time.Sleep للمزامنة بدلاً من الـ primitives المناسبة
- إغلاق القنوات من جانب المستقبل مما يسبب panics
- تجاهل ctx.Done في الحلقات طويلة المدى مما يؤدي إلى تسريبات goroutine