<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AzLearn — منصة التعلّم من عزيز ويرز</title><link>https://learn.azizwares.sa/</link><description>Recent content on AzLearn — منصة التعلّم من عزيز ويرز</description><generator>Hugo</generator><language>ar</language><atom:link href="https://learn.azizwares.sa/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker</title><link>https://learn.azizwares.sa/go/13-production/01-docker/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/13-production/01-docker/</guid><description>&lt;h2 id="docker--حاويات-go"&gt;Docker — حاويات Go&lt;/h2&gt;
&lt;p&gt;Go من أفضل اللغات لـ Docker — لأنها تُنتج ملفاً تنفيذياً واحداً بدون اعتماديات. هذا يعني صور Docker صغيرة جداً وآمنة.&lt;/p&gt;
&lt;h3 id="لماذا-go--docker--"&gt;لماذا Go + Docker = ❤️&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;ملف تنفيذي واحد (static binary) — لا تحتاج runtime&lt;/li&gt;
&lt;li&gt;يمكن استخدام صورة &lt;code&gt;scratch&lt;/code&gt; (فارغة!) — أصغر صورة ممكنة&lt;/li&gt;
&lt;li&gt;البناء سريع مع cache الوحدات&lt;/li&gt;
&lt;li&gt;Cross-compilation مدمج&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="dockerfile-بسيط"&gt;Dockerfile بسيط&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-e2217bd253874731695edfc9d76925d1"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-e2217bd253874731695edfc9d76925d1-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(`# ❌ Dockerfile بسيط (غير مُحسّن)
FROM golang:1.22

WORKDIR /app
COPY . .
RUN go build -o server .

CMD [&amp;#34;./server&amp;#34;]

# الحجم: ~1.2GB! 😱
# يحتوي كل أدوات Go &amp;#43; نظام تشغيل كامل`)

 fmt.Println()

 fmt.Println(`# ✅ Dockerfile متعدد المراحل (مُحسّن)
FROM golang:1.22-alpine AS builder

WORKDIR /app

# نسخ ملفات الوحدة أولاً للاستفادة من cache
COPY go.mod go.sum ./
RUN go mod download

# نسخ الكود والبناء
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags=&amp;#34;-s -w&amp;#34; -o server .

# المرحلة النهائية — صورة scratch فارغة!
FROM scratch

# نسخ شهادات SSL (للاتصال HTTPS)
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/server /server

EXPOSE 8080
CMD [&amp;#34;/server&amp;#34;]

# الحجم: ~10-15MB! 🚀`)
}&lt;/textarea&gt;
 &lt;div id="pg-e2217bd253874731695edfc9d76925d1-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-e2217bd253874731695edfc9d76925d1-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="شرح-البناء-المتعدد-المراحل"&gt;شرح البناء المتعدد المراحل&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-d76d3f6b5d24511f1f190546de5cf9c6"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-d76d3f6b5d24511f1f190546de5cf9c6-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(&amp;#34;=== مراحل البناء ===\n&amp;#34;)

 stages := []struct {
 stage string
 desc string
 size string
 }{
 {&amp;#34;golang:1.22-alpine&amp;#34;, &amp;#34;مرحلة البناء — تحتوي كل الأدوات&amp;#34;, &amp;#34;~300MB&amp;#34;},
 {&amp;#34;scratch&amp;#34;, &amp;#34;المرحلة النهائية — فارغة تماماً!&amp;#34;, &amp;#34;0MB&amp;#34;},
 {&amp;#34;الصورة النهائية&amp;#34;, &amp;#34;الملف التنفيذي &amp;#43; شهادات SSL فقط&amp;#34;, &amp;#34;~10-15MB&amp;#34;},
 }

 for i, s := range stages {
 fmt.Printf(&amp;#34;%d. %s\n %s (الحجم: %s)\n\n&amp;#34;, i&amp;#43;1, s.stage, s.desc, s.size)
 }

 fmt.Println(&amp;#34;=== الأعلام المهمة ===&amp;#34;)
 fmt.Println(&amp;#34;CGO_ENABLED=0 → بناء ثابت بدون اعتماديات C&amp;#34;)
 fmt.Println(&amp;#34;GOOS=linux → بناء لنظام Linux&amp;#34;)
 fmt.Println(&amp;#34;-ldflags=\&amp;#34;-s -w\&amp;#34; → حذف معلومات التصحيح (أصغر)&amp;#34;)
 fmt.Println(&amp;#34;-trimpath → حذف مسارات الملفات المحلية&amp;#34;)

 fmt.Println(&amp;#34;\n=== بدائل scratch ===&amp;#34;)
 fmt.Println(&amp;#34;scratch → 0MB (لا shell، لا أدوات)&amp;#34;)
 fmt.Println(&amp;#34;alpine → ~5MB (shell &amp;#43; أدوات أساسية)&amp;#34;)
 fmt.Println(&amp;#34;distroless → ~2MB (أمان &amp;#43; شهادات)&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-d76d3f6b5d24511f1f190546de5cf9c6-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-d76d3f6b5d24511f1f190546de5cf9c6-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="docker-compose"&gt;Docker Compose&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-25d97b3f5687e2282bb8bd558679fee2"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-25d97b3f5687e2282bb8bd558679fee2-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(`# docker-compose.yml
version: &amp;#34;3.9&amp;#34;

services:
 app:
 build: .
 ports:
 - &amp;#34;8080:8080&amp;#34;
 environment:
 - DATABASE_URL=postgres://user:pass@db:5432/mydb?sslmode=disable
 - ENV=production
 depends_on:
 db:
 condition: service_healthy
 restart: unless-stopped

 db:
 image: postgres:16-alpine
 environment:
 POSTGRES_USER: user
 POSTGRES_PASSWORD: pass
 POSTGRES_DB: mydb
 volumes:
 - pgdata:/var/lib/postgresql/data
 healthcheck:
 test: [&amp;#34;CMD-SHELL&amp;#34;, &amp;#34;pg_isready -U user&amp;#34;]
 interval: 5s
 timeout: 5s
 retries: 5

 redis:
 image: redis:7-alpine
 ports:
 - &amp;#34;6379:6379&amp;#34;

volumes:
 pgdata:`)

 fmt.Println(&amp;#34;\n=== الأوامر ===&amp;#34;)
 fmt.Println(&amp;#34;docker compose up -d → تشغيل في الخلفية&amp;#34;)
 fmt.Println(&amp;#34;docker compose logs -f app → عرض السجلات&amp;#34;)
 fmt.Println(&amp;#34;docker compose down → إيقاف وحذف&amp;#34;)
 fmt.Println(&amp;#34;docker compose build --no-cache → إعادة البناء&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-25d97b3f5687e2282bb8bd558679fee2-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-25d97b3f5687e2282bb8bd558679fee2-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="dockerignore"&gt;.dockerignore&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.gitignore
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Makefile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vendor/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tmp/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.env
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="أفضل-ممارسات-docker--go"&gt;أفضل ممارسات Docker + Go&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-24c9c91b1d32a840164cf295200765e5"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-24c9c91b1d32a840164cf295200765e5-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 tips := []struct {
 tip string
 why string
 }{
 {&amp;#34;استخدم multi-stage build&amp;#34;, &amp;#34;حجم أصغر 100x&amp;#34;},
 {&amp;#34;CGO_ENABLED=0 دائماً&amp;#34;, &amp;#34;بناء ثابت بدون مشاكل&amp;#34;},
 {&amp;#34;انسخ go.mod أولاً&amp;#34;, &amp;#34;cache أفضل للاعتماديات&amp;#34;},
 {&amp;#34;استخدم scratch أو distroless&amp;#34;, &amp;#34;أقل سطح هجوم&amp;#34;},
 {&amp;#34;لا تشغّل كـ root&amp;#34;, &amp;#34;أمان أفضل&amp;#34;},
 {&amp;#34;أضف healthcheck&amp;#34;, &amp;#34;Kubernetes/compose يعرف الحالة&amp;#34;},
 {&amp;#34;استخدم .dockerignore&amp;#34;, &amp;#34;بناء أسرع&amp;#34;},
 }

 fmt.Println(&amp;#34;=== أفضل ممارسات Docker &amp;#43; Go ===\n&amp;#34;)
 for i, t := range tips {
 fmt.Printf(&amp;#34;%d. %s\n → %s\n\n&amp;#34;, i&amp;#43;1, t.tip, t.why)
 }
}&lt;/textarea&gt;
 &lt;div id="pg-24c9c91b1d32a840164cf295200765e5-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-24c9c91b1d32a840164cf295200765e5-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="إضافة-مستخدم-غير-root"&gt;إضافة مستخدم غير root&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-dockerfile" data-lang="dockerfile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;FROM&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;scratch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;# إضافة مستخدم — Add non-root user&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;COPY&lt;/span&gt; --from&lt;span style="color:#ff79c6"&gt;=&lt;/span&gt;builder /etc/passwd /etc/passwd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;COPY&lt;/span&gt; --from&lt;span style="color:#ff79c6"&gt;=&lt;/span&gt;builder /app/server /server
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;USER&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;nobody&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;CMD&lt;/span&gt; [&lt;span style="color:#f1fa8c"&gt;&amp;#34;/server&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;div class="challenge my-6 bg-surface-dark border-2 border-indigo/30 rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-gradient-to-l from-indigo/10 to-transparent border-b border-surface-dark-border"&gt;
 &lt;span class="text-indigo dark:text-indigo-light text-sm font-bold" dir="rtl"&gt;تحدي — Challenge&lt;/span&gt;
 &lt;div class="flex gap-2"&gt;
 
 &lt;button data-hint-toggle="ch-af72e975828fe5b394b67bd0622a4e3e-hint"
 class="text-gray-400 text-sm hover:text-gold transition"&gt;تلميح&lt;/button&gt;
 
 &lt;button data-challenge="ch-af72e975828fe5b394b67bd0622a4e3e" data-expected="المرحلة 1: golang:1.22-alpine (بناء)\nالمرحلة 2: scratch (تشغيل)\nالحجم: ~12MB\nالأمان: لا root، لا shell"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition"&gt;
 &amp;#9654; تحقق — Check
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;/div&gt;
 
 &lt;div id="ch-af72e975828fe5b394b67bd0622a4e3e-hint" class="hidden px-4 py-2 bg-indigo/5 text-gray-300 text-sm border-b border-surface-dark-border" dir="rtl"&gt;
 اطبع ملخص استراتيجية Docker المثالية لـ Go
 &lt;/div&gt;
 
 &lt;textarea id="ch-af72e975828fe5b394b67bd0622a4e3e-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 // اطبع ملخص استراتيجية Docker لـ Go:
 // المرحلة 1, المرحلة 2, الحجم, الأمان
 // اكتب الكود هنا
}&lt;/textarea&gt;
 &lt;div id="ch-af72e975828fe5b394b67bd0622a4e3e-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div id="ch-af72e975828fe5b394b67bd0622a4e3e-status" class="px-4 py-2 text-sm font-bold"&gt;&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="ch-af72e975828fe5b394b67bd0622a4e3e-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;</description></item><item><title>أساسيات HTTP</title><link>https://learn.azizwares.sa/go/08-http/01-http-basics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/08-http/01-http-basics/</guid><description>&lt;h2 id="أساسيات-http--http-basics"&gt;أساسيات HTTP — HTTP Basics&lt;/h2&gt;
&lt;p&gt;من أعظم نقاط قوة Go أن مكتبتها القياسية تحتوي على خادم HTTP إنتاجي — لا تحتاج Express أو Flask أو أي framework. حزمة &lt;code&gt;net/http&lt;/code&gt; وحدها كافية لبناء خوادم تخدم ملايين الطلبات.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ملاحظة مهمة:&lt;/strong&gt; أمثلة HTTP لا يمكن تشغيلها على Go Playground لأنها تحتاج شبكة. اقرأ الكود وافهمه، ثم جرّبه على جهازك المحلي.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="أبسط-خادم-http"&gt;أبسط خادم HTTP&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-03f902a091b29e4116d47118a1dc1754"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-03f902a091b29e4116d47118a1dc1754-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;net/http&amp;#34;
)

func main() {
 // معالج بسيط — Simple handler
 http.HandleFunc(&amp;#34;/&amp;#34;, func(w http.ResponseWriter, r *http.Request) {
 fmt.Fprintf(w, &amp;#34;مرحباً بالعالم! 🌍&amp;#34;)
 })

 http.HandleFunc(&amp;#34;/salam&amp;#34;, func(w http.ResponseWriter, r *http.Request) {
 fmt.Fprintf(w, &amp;#34;السلام عليكم ورحمة الله وبركاته&amp;#34;)
 })

 fmt.Println(&amp;#34;الخادم يعمل على http://localhost:8080&amp;#34;)
 // شغّل هذا على جهازك — Run this locally
 // http.ListenAndServe(&amp;#34;:8080&amp;#34;, nil)
}&lt;/textarea&gt;
 &lt;div id="pg-03f902a091b29e4116d47118a1dc1754-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-03f902a091b29e4116d47118a1dc1754-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="واجهة-httphandler"&gt;واجهة http.Handler&lt;/h3&gt;
&lt;p&gt;كل شيء في &lt;code&gt;net/http&lt;/code&gt; يدور حول هذه الواجهة:&lt;/p&gt;</description></item><item><title>أساسيات SQL</title><link>https://learn.azizwares.sa/go/09-databases/01-sql-basics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/09-databases/01-sql-basics/</guid><description>&lt;h2 id="أساسيات-sql--sql-basics"&gt;أساسيات SQL — SQL Basics&lt;/h2&gt;
&lt;p&gt;حزمة &lt;code&gt;database/sql&lt;/code&gt; هي الواجهة الموحدة للتعامل مع قواعد البيانات العلائقية في Go. التصميم ذكي: الحزمة تُعرّف الواجهة، و&lt;strong&gt;المشغّلات&lt;/strong&gt; (drivers) تُنفّذها لكل قاعدة بيانات.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ملاحظة:&lt;/strong&gt; أمثلة قواعد البيانات لا يمكن تشغيلها مباشرة على Go Playground لأنها تحتاج قاعدة بيانات فعلية. الكود هنا للقراءة والفهم — جرّبه محلياً.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="بنية-الحزمة"&gt;بنية الحزمة&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;database/sql (الواجهة — Interface)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ↓
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;مشغّل (Driver)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ↓
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;قاعدة البيانات (PostgreSQL / MySQL / SQLite)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;المشغّلات الشائعة:&lt;/p&gt;</description></item><item><title>أساسيات الأخطاء</title><link>https://learn.azizwares.sa/go/06-errors/01-error-basics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/06-errors/01-error-basics/</guid><description>&lt;h2 id="أساسيات-الأخطاء--error-basics"&gt;أساسيات الأخطاء — Error Basics&lt;/h2&gt;
&lt;p&gt;في أغلب اللغات، الأخطاء تُعالج عبر الاستثناءات (exceptions) — تُرمى في مكان وتُلتقط في مكان آخر. Go اختارت طريقاً مختلفاً تماماً: &lt;strong&gt;الأخطاء قيم عادية&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;هذا يعني أنك تتعامل مع الخطأ كما تتعامل مع أي قيمة — تفحصه، تمرره، تغلّفه، أو تتجاهله (وهذا خطأ!).&lt;/p&gt;
&lt;h3 id="واجهة-error"&gt;واجهة error&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;error&lt;/code&gt; هو نوع مُدمج في Go — واجهة بأسلوب واحد:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;type&lt;/span&gt; &lt;span style="color:#8be9fd"&gt;error&lt;/span&gt; &lt;span style="color:#8be9fd;font-style:italic"&gt;interface&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#50fa7b"&gt;Error&lt;/span&gt;() &lt;span style="color:#8be9fd"&gt;string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;أي نوع يُنفّذ &lt;code&gt;Error() string&lt;/code&gt; يُعتبر خطأ. بهذه البساطة.&lt;/p&gt;</description></item><item><title>أساسيات الاختبار</title><link>https://learn.azizwares.sa/go/10-testing/01-basics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/10-testing/01-basics/</guid><description>&lt;h2 id="أساسيات-الاختبار--testing-basics"&gt;أساسيات الاختبار — Testing Basics&lt;/h2&gt;
&lt;p&gt;الاختبارات في Go مواطنون من الدرجة الأولى — مدمجة في اللغة والأدوات. لا تحتاج Jest أو pytest أو JUnit. كل ما تحتاجه هو ملف ينتهي بـ &lt;code&gt;_test.go&lt;/code&gt; وأمر &lt;code&gt;go test&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="القواعد-الأساسية"&gt;القواعد الأساسية&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;ملف الاختبار يجب أن ينتهي بـ &lt;code&gt;_test.go&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;دوال الاختبار تبدأ بـ &lt;code&gt;Test&lt;/code&gt; مع حرف كبير&lt;/li&gt;
&lt;li&gt;تأخذ معامل واحد: &lt;code&gt;*testing.T&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;لا تُرجع شيئاً&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-cbc9c92831a69ab369c9d386a82f81dc"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-cbc9c92831a69ab369c9d386a82f81dc-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;strings&amp;#34;
)

// الدوال المُختبرة — Functions to test
func Add(a, b int) int {
 return a &amp;#43; b
}

func IsEven(n int) bool {
 return n%2 == 0
}

func Reverse(s string) string {
 runes := []rune(s)
 for i, j := 0, len(runes)-1; i &amp;lt; j; i, j = i&amp;#43;1, j-1 {
 runes[i], runes[j] = runes[j], runes[i]
 }
 return string(runes)
}

func ToTitle(s string) string {
 // ملاحظة: strings.Title مهملة منذ Go 1.18، استخدم golang.org/x/text/cases بدلاً منها
 // Note: strings.Title is deprecated since Go 1.18, use golang.org/x/text/cases instead
 return strings.Title(strings.ToLower(s))
}

// محاكاة الاختبارات — Simulated tests
func testAdd() {
 if Add(2, 3) != 5 {
 fmt.Println(&amp;#34;❌ FAIL: TestAdd — 2&amp;#43;3 يجب أن يكون 5&amp;#34;)
 } else {
 fmt.Println(&amp;#34;✅ PASS: TestAdd&amp;#34;)
 }
}

func testIsEven() {
 cases := []struct{ n int; want bool }{
 {0, true}, {1, false}, {2, true}, {-4, true}, {7, false},
 }
 allPassed := true
 for _, c := range cases {
 if IsEven(c.n) != c.want {
 fmt.Printf(&amp;#34;❌ FAIL: IsEven(%d) = %v، المتوقع %v\n&amp;#34;, c.n, !c.want, c.want)
 allPassed = false
 }
 }
 if allPassed {
 fmt.Println(&amp;#34;✅ PASS: TestIsEven&amp;#34;)
 }
}

func testReverse() {
 result := Reverse(&amp;#34;مرحبا&amp;#34;)
 if result != &amp;#34;ابحرم&amp;#34; {
 fmt.Printf(&amp;#34;❌ FAIL: Reverse — حصلت على %q\n&amp;#34;, result)
 } else {
 fmt.Println(&amp;#34;✅ PASS: TestReverse&amp;#34;)
 }
}

func main() {
 fmt.Println(&amp;#34;=== تشغيل الاختبارات ===\n&amp;#34;)
 testAdd()
 testIsEven()
 testReverse()

 fmt.Println(&amp;#34;\n=== في الملف الحقيقي ===&amp;#34;)
 fmt.Println(&amp;#34;الملف: math_test.go&amp;#34;)
 fmt.Println(&amp;#34;التشغيل: go test ./...&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-cbc9c92831a69ab369c9d386a82f81dc-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-cbc9c92831a69ab369c9d386a82f81dc-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="ملف-الاختبار-الحقيقي"&gt;ملف الاختبار الحقيقي&lt;/h3&gt;
&lt;p&gt;هكذا يبدو ملف اختبار Go الفعلي:&lt;/p&gt;</description></item><item><title>الأساليب</title><link>https://learn.azizwares.sa/go/05-interfaces/01-methods/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/05-interfaces/01-methods/</guid><description>&lt;h2 id="الأساليب--methods"&gt;الأساليب — Methods&lt;/h2&gt;
&lt;p&gt;في Go لا توجد كلاسات (Classes) كما في Java أو Python، لكن هناك بديل أنيق وقوي: &lt;strong&gt;الأساليب&lt;/strong&gt; (Methods). الأسلوب هو ببساطة دالة مرتبطة بنوع معين. هذا يعني أنك تستطيع إضافة سلوك لأي نوع تُعرّفه — سواء كان struct أو حتى نوع بسيط مثل &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="تعريف-أسلوب-بسيط"&gt;تعريف أسلوب بسيط&lt;/h3&gt;
&lt;p&gt;الفرق بين الدالة العادية والأسلوب هو وجود &lt;strong&gt;مُستقبِل&lt;/strong&gt; (Receiver) بين كلمة &lt;code&gt;func&lt;/code&gt; واسم الدالة:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// دالة عادية — Regular function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;Area&lt;/span&gt;(width, height &lt;span style="color:#8be9fd"&gt;float64&lt;/span&gt;) &lt;span style="color:#8be9fd"&gt;float64&lt;/span&gt; { &lt;span style="color:#ff79c6"&gt;...&lt;/span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// أسلوب على نوع — Method on a type&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; (r Rectangle) &lt;span style="color:#50fa7b"&gt;Area&lt;/span&gt;() &lt;span style="color:#8be9fd"&gt;float64&lt;/span&gt; { &lt;span style="color:#ff79c6"&gt;...&lt;/span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;المُستقبِل &lt;code&gt;(r Rectangle)&lt;/code&gt; يربط هذا الأسلوب بالنوع &lt;code&gt;Rectangle&lt;/code&gt;. الآن يمكنك استدعاؤه عبر &lt;code&gt;rect.Area()&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>السياق</title><link>https://learn.azizwares.sa/go/12-advanced/01-context/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/12-advanced/01-context/</guid><description>&lt;h2 id="السياق--context"&gt;السياق — Context&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;context.Context&lt;/code&gt; هي واحدة من أهم واجهات Go — تُستخدم لإلغاء العمليات، تحديد المهل الزمنية، وتمرير بيانات عبر طبقات البرنامج. كل طلب HTTP، كل استعلام قاعدة بيانات، كل عملية طويلة — يجب أن تأخذ context.&lt;/p&gt;
&lt;h3 id="لماذا-context"&gt;لماذا Context؟&lt;/h3&gt;
&lt;p&gt;تخيّل مستخدم فتح صفحة ثم أغلق المتصفح. بدون context، الخادم يستمر في المعالجة بلا فائدة! مع context، الخادم يعرف أن العميل رحل ويتوقف فوراً.&lt;/p&gt;
&lt;h3 id="أنواع-context"&gt;أنواع Context&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-87e670896d7c4ac004a8e1a1393acc5d"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-87e670896d7c4ac004a8e1a1393acc5d-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;context&amp;#34;
 &amp;#34;fmt&amp;#34;
 &amp;#34;time&amp;#34;
)

func main() {
 // 1. context.Background — الجذر — Root context
 ctx := context.Background()
 fmt.Printf(&amp;#34;Background: %v\n&amp;#34;, ctx)

 // 2. context.TODO — مؤقت حتى تقرر ماذا تستخدم
 todoCtx := context.TODO()
 fmt.Printf(&amp;#34;TODO: %v\n&amp;#34;, todoCtx)

 // 3. WithCancel — إلغاء يدوي — Manual cancellation
 cancelCtx, cancel := context.WithCancel(ctx)
 fmt.Printf(&amp;#34;WithCancel: %v (Err: %v)\n&amp;#34;, cancelCtx, cancelCtx.Err())
 cancel() // إلغاء!
 fmt.Printf(&amp;#34;بعد الإلغاء: Err = %v\n&amp;#34;, cancelCtx.Err())

 // 4. WithTimeout — إلغاء بعد مدة — Auto-cancel after duration
 timeoutCtx, timeoutCancel := context.WithTimeout(ctx, 100*time.Millisecond)
 defer timeoutCancel()
 fmt.Printf(&amp;#34;WithTimeout: deadline in 100ms\n&amp;#34;)

 // 5. WithDeadline — إلغاء في وقت محدد
 deadline := time.Now().Add(5 * time.Second)
 deadlineCtx, deadlineCancel := context.WithDeadline(ctx, deadline)
 defer deadlineCancel()
 d, _ := deadlineCtx.Deadline()
 fmt.Printf(&amp;#34;WithDeadline: %v\n&amp;#34;, d.Format(&amp;#34;15:04:05&amp;#34;))

 _ = timeoutCtx
}&lt;/textarea&gt;
 &lt;div id="pg-87e670896d7c4ac004a8e1a1393acc5d-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-87e670896d7c4ac004a8e1a1393acc5d-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الإلغاء--cancellation"&gt;الإلغاء — Cancellation&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-d4759075d7ec3c2d65b2f756885efc6c"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-d4759075d7ec3c2d65b2f756885efc6c-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;context&amp;#34;
 &amp;#34;fmt&amp;#34;
 &amp;#34;time&amp;#34;
)

// عملية طويلة قابلة للإلغاء — Long operation with cancellation
func longOperation(ctx context.Context, name string) {
 for i := 1; i &amp;lt;= 10; i&amp;#43;&amp;#43; {
 select {
 case &amp;lt;-ctx.Done():
 fmt.Printf(&amp;#34;[%s] ⛔ تم الإلغاء عند الخطوة %d: %v\n&amp;#34;, name, i, ctx.Err())
 return
 default:
 fmt.Printf(&amp;#34;[%s] الخطوة %d\n&amp;#34;, name, i)
 time.Sleep(50 * time.Millisecond)
 }
 }
 fmt.Printf(&amp;#34;[%s] ✅ اكتمل!\n&amp;#34;, name)
}

func main() {
 // إلغاء يدوي بعد 150ms — Cancel manually after 150ms
 ctx, cancel := context.WithCancel(context.Background())

 go longOperation(ctx, &amp;#34;عملية-1&amp;#34;)

 time.Sleep(150 * time.Millisecond)
 cancel() // إلغاء!
 time.Sleep(50 * time.Millisecond)

 fmt.Println(&amp;#34;\n--- المهلة الزمنية ---&amp;#34;)

 // مهلة 120ms — Timeout after 120ms
 timeoutCtx, timeoutCancel := context.WithTimeout(context.Background(), 120*time.Millisecond)
 defer timeoutCancel()

 longOperation(timeoutCtx, &amp;#34;عملية-2&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-d4759075d7ec3c2d65b2f756885efc6c-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-d4759075d7ec3c2d65b2f756885efc6c-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="withvalue--تمرير-بيانات"&gt;WithValue — تمرير بيانات&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-292b994b1ba7d7c6a5e21bc884094720"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-292b994b1ba7d7c6a5e21bc884094720-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;context&amp;#34;
 &amp;#34;fmt&amp;#34;
)

// مفاتيح مخصصة — Custom keys (تجنّب string!)
type contextKey string

const (
 userIDKey contextKey = &amp;#34;userID&amp;#34;
 requestIDKey contextKey = &amp;#34;requestID&amp;#34;
)

// دالة تقرأ من Context — Read from context
func processRequest(ctx context.Context) {
 userID, ok := ctx.Value(userIDKey).(int)
 if !ok {
 fmt.Println(&amp;#34;❌ لا يوجد userID في السياق&amp;#34;)
 return
 }

 requestID, _ := ctx.Value(requestIDKey).(string)
 fmt.Printf(&amp;#34;معالجة الطلب %s للمستخدم %d\n&amp;#34;, requestID, userID)
}

func main() {
 ctx := context.Background()

 // إضافة قيم — Add values
 ctx = context.WithValue(ctx, userIDKey, 42)
 ctx = context.WithValue(ctx, requestIDKey, &amp;#34;req-abc-123&amp;#34;)

 processRequest(ctx)

 // سياق بدون userID — Context without userID
 emptyCtx := context.Background()
 processRequest(emptyCtx)
}&lt;/textarea&gt;
 &lt;div id="pg-292b994b1ba7d7c6a5e21bc884094720-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-292b994b1ba7d7c6a5e21bc884094720-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;تحذير:&lt;/strong&gt; لا تستخدم &lt;code&gt;WithValue&lt;/code&gt; لتمرير معاملات الدوال! استخدمها فقط للبيانات العابرة (request ID, auth token, trace ID).&lt;/p&gt;</description></item><item><title>الغوروتينات</title><link>https://learn.azizwares.sa/go/07-concurrency/01-goroutines/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/07-concurrency/01-goroutines/</guid><description>&lt;h2 id="الغوروتينات--goroutines"&gt;الغوروتينات — Goroutines&lt;/h2&gt;
&lt;p&gt;تخيّل أنك في مطعم. في النموذج التقليدي، هناك نادل واحد يخدم طاولة واحدة في كل مرة — إذا طاولة طلبت شيئاً يأخذ وقتاً، كل الطاولات الأخرى تنتظر. في نموذج Go، هناك عشرات النوادل الخفيفين يخدمون كل الطاولات بالتوازي — وكل نادل لا يكلّف شيئاً تقريباً.&lt;/p&gt;
&lt;p&gt;هذا هو مفهوم goroutine: &lt;strong&gt;خيط تنفيذ خفيف الوزن&lt;/strong&gt; يعمل بالتزامن مع باقي البرنامج.&lt;/p&gt;
&lt;h3 id="ما-هي-الـ-goroutine"&gt;ما هي الـ goroutine؟&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;هي دالة تعمل &lt;strong&gt;بشكل متزامن&lt;/strong&gt; مع دوال أخرى&lt;/li&gt;
&lt;li&gt;أخف بكثير من خيوط نظام التشغيل (thread) — حوالي 2KB من الذاكرة مقابل ~1MB للخيط&lt;/li&gt;
&lt;li&gt;يمكنك تشغيل &lt;strong&gt;آلاف أو ملايين&lt;/strong&gt; منها بدون مشاكل&lt;/li&gt;
&lt;li&gt;Go runtime يدير جدولتها (scheduling) تلقائياً&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="كلمة-go"&gt;كلمة go&lt;/h3&gt;
&lt;p&gt;لتشغيل goroutine، أضف كلمة &lt;code&gt;go&lt;/code&gt; قبل استدعاء الدالة:&lt;/p&gt;</description></item><item><title>المتغيرات والثوابت</title><link>https://learn.azizwares.sa/go/02-basics/01-variables/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/02-basics/01-variables/</guid><description>&lt;h2 id="المتغيرات-والثوابت--variables--constants"&gt;المتغيرات والثوابت — Variables &amp;amp; Constants&lt;/h2&gt;
&lt;p&gt;المتغيرات هي صناديق تخزين البيانات في أي لغة برمجة. في Go، هناك عدة طرق لتعريف المتغيرات، وكل طريقة لها استخدامها المناسب.&lt;/p&gt;
&lt;h3 id="تعريف-المتغيرات-بـ-var"&gt;تعريف المتغيرات بـ &lt;code&gt;var&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;الطريقة الكلاسيكية لتعريف متغير:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;var&lt;/span&gt; name &lt;span style="color:#8be9fd"&gt;string&lt;/span&gt; = &lt;span style="color:#f1fa8c"&gt;&amp;#34;عزيز&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;var&lt;/span&gt; age &lt;span style="color:#8be9fd"&gt;int&lt;/span&gt; = &lt;span style="color:#bd93f9"&gt;25&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;var&lt;/span&gt; isStudent &lt;span style="color:#8be9fd"&gt;bool&lt;/span&gt; = &lt;span style="color:#ff79c6"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;الصيغة: &lt;code&gt;var اسم_المتغير نوع_البيانات = القيمة&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;يمكنك حذف النوع إذا أعطيت قيمة — Go يستنتج النوع تلقائياً (type inference):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;var&lt;/span&gt; name = &lt;span style="color:#f1fa8c"&gt;&amp;#34;عزيز&amp;#34;&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// Go يعرف أنها string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;var&lt;/span&gt; age = &lt;span style="color:#bd93f9"&gt;25&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// Go يعرف أنها int&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;ويمكنك التعريف بدون قيمة — ستأخذ &lt;strong&gt;القيمة الصفرية&lt;/strong&gt; (zero value):&lt;/p&gt;</description></item><item><title>المصفوفات والشرائح</title><link>https://learn.azizwares.sa/go/03-data-structures/01-arrays-slices/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/03-data-structures/01-arrays-slices/</guid><description>&lt;h2 id="المصفوفات-والشرائح--arrays--slices"&gt;المصفوفات والشرائح — Arrays &amp;amp; Slices&lt;/h2&gt;
&lt;p&gt;في Go هناك نوعان لتخزين مجموعة عناصر: &lt;strong&gt;المصفوفات&lt;/strong&gt; (Arrays) ذات الحجم الثابت، و&lt;strong&gt;الشرائح&lt;/strong&gt; (Slices) ذات الحجم المتغير. في الممارسة العملية، الشرائح هي ما ستستخدمه ٩٩٪ من الوقت.&lt;/p&gt;
&lt;h3 id="المصفوفات-arrays"&gt;المصفوفات (Arrays)&lt;/h3&gt;
&lt;p&gt;المصفوفة لها حجم ثابت يُحدد عند التعريف ولا يمكن تغييره:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-1045bad624b5edc5317fa7c9162b1704"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-1045bad624b5edc5317fa7c9162b1704-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 // تعريف مصفوفة — Declare an array
 var numbers [5]int
 numbers[0] = 10
 numbers[1] = 20
 numbers[4] = 50
 fmt.Println(&amp;#34;المصفوفة:&amp;#34;, numbers)
 fmt.Println(&amp;#34;الطول:&amp;#34;, len(numbers))
 
 // تعريف مع قيم — Array literal
 fruits := [3]string{&amp;#34;تفاح&amp;#34;, &amp;#34;موز&amp;#34;, &amp;#34;برتقال&amp;#34;}
 fmt.Println(&amp;#34;الفواكه:&amp;#34;, fruits)
 
 // Go يحسب الحجم — Let Go count
 colors := [...]string{&amp;#34;أحمر&amp;#34;, &amp;#34;أخضر&amp;#34;, &amp;#34;أزرق&amp;#34;}
 fmt.Println(&amp;#34;الألوان:&amp;#34;, colors)
 fmt.Println(&amp;#34;العدد:&amp;#34;, len(colors))
 
 // المرور على المصفوفة — Iterate
 for i, fruit := range fruits {
 fmt.Printf(&amp;#34; %d: %s\n&amp;#34;, i, fruit)
 }
}&lt;/textarea&gt;
 &lt;div id="pg-1045bad624b5edc5317fa7c9162b1704-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-1045bad624b5edc5317fa7c9162b1704-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;قيود المصفوفات:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>الوحدات</title><link>https://learn.azizwares.sa/go/11-packages/01-modules/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/11-packages/01-modules/</guid><description>&lt;h2 id="الوحدات--modules"&gt;الوحدات — Modules&lt;/h2&gt;
&lt;p&gt;الوحدات (Modules) هي نظام إدارة الاعتماديات في Go منذ الإصدار 1.11. قبلها كان هناك GOPATH الذي كان مصدر إحباط للكثيرين. الآن النظام بسيط ومنظم.&lt;/p&gt;
&lt;h3 id="ما-هي-الوحدة"&gt;ما هي الوحدة؟&lt;/h3&gt;
&lt;p&gt;الوحدة = مجموعة من الحزم Go ذات العلاقة، تُدار كوحدة واحدة. كل وحدة لها ملف &lt;code&gt;go.mod&lt;/code&gt; في الجذر.&lt;/p&gt;
&lt;h3 id="إنشاء-وحدة-جديدة"&gt;إنشاء وحدة جديدة&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-8d3dfb323fc96c8bf39bf3e0c8214266"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-8d3dfb323fc96c8bf39bf3e0c8214266-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(&amp;#34;=== إنشاء وحدة جديدة ===\n&amp;#34;)

 steps := []struct {
 cmd string
 desc string
 }{
 {&amp;#34;mkdir myproject &amp;amp;&amp;amp; cd myproject&amp;#34;, &amp;#34;إنشاء مجلد المشروع&amp;#34;},
 {&amp;#34;go mod init github.com/user/myproject&amp;#34;, &amp;#34;تهيئة الوحدة&amp;#34;},
 {&amp;#34;# يُنشئ ملف go.mod&amp;#34;, &amp;#34;&amp;#34;},
 }

 for _, s := range steps {
 if s.desc != &amp;#34;&amp;#34; {
 fmt.Printf(&amp;#34;$ %s\n → %s\n\n&amp;#34;, s.cmd, s.desc)
 }
 }

 fmt.Println(&amp;#34;=== ملف go.mod ===&amp;#34;)
 fmt.Println(`module github.com/user/myproject

go 1.22

require (
 github.com/gin-gonic/gin v1.9.1
 github.com/lib/pq v1.10.9
)

require (
 // اعتماديات غير مباشرة — Indirect dependencies
 golang.org/x/net v0.17.0 // indirect
)`)
}&lt;/textarea&gt;
 &lt;div id="pg-8d3dfb323fc96c8bf39bf3e0c8214266-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-8d3dfb323fc96c8bf39bf3e0c8214266-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="مسار-الوحدة--module-path"&gt;مسار الوحدة — Module Path&lt;/h3&gt;
&lt;p&gt;مسار الوحدة يُحدد هوية مشروعك:&lt;/p&gt;</description></item><item><title>بناء أداة CLI</title><link>https://learn.azizwares.sa/go/04-practical/01-cli-tool/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/04-practical/01-cli-tool/</guid><description>&lt;h2 id="بناء-أداة-cli--building-a-cli-tool"&gt;بناء أداة CLI — Building a CLI Tool&lt;/h2&gt;
&lt;p&gt;أحد أقوى استخدامات Go هو بناء أدوات سطر الأوامر (CLI tools). Go تُنتج ملفاً تنفيذياً واحداً — لا تبعيات، لا runtime — وهذا مثالي لأدوات CLI.&lt;/p&gt;
&lt;h3 id="osargs--المعاملات-البسيطة"&gt;os.Args — المعاملات البسيطة&lt;/h3&gt;
&lt;p&gt;أبسط طريقة لقراءة معاملات سطر الأوامر:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-d3addbbf7a73975c3f327107b2c6d979"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-d3addbbf7a73975c3f327107b2c6d979-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 // os.Args شريحة تحتوي كل المعاملات
 // os.Args[0] = اسم البرنامج
 // os.Args[1:] = المعاملات
 
 args := os.Args
 fmt.Println(&amp;#34;كل المعاملات:&amp;#34;, args)
 fmt.Println(&amp;#34;اسم البرنامج:&amp;#34;, args[0])
 
 if len(args) &amp;gt; 1 {
 fmt.Println(&amp;#34;المعاملات:&amp;#34;, args[1:])
 for i, arg := range args[1:] {
 fmt.Printf(&amp;#34; معامل %d: %s\n&amp;#34;, i&amp;#43;1, arg)
 }
 } else {
 fmt.Println(&amp;#34;لم تُمرر أي معاملات!&amp;#34;)
 fmt.Println(&amp;#34;الاستخدام: البرنامج &amp;lt;اسم&amp;gt; [خيارات...]&amp;#34;)
 }
}&lt;/textarea&gt;
 &lt;div id="pg-d3addbbf7a73975c3f327107b2c6d979-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-d3addbbf7a73975c3f327107b2c6d979-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="حزمة-flag--خيارات-متقدمة"&gt;حزمة flag — خيارات متقدمة&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;flag&lt;/code&gt; تُسهّل تعريف خيارات مثل &lt;code&gt;--name أحمد --age 25&lt;/code&gt;:&lt;/p&gt;</description></item><item><title>ما هي لغة Go؟</title><link>https://learn.azizwares.sa/go/01-introduction/01-what-is-go/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/01-introduction/01-what-is-go/</guid><description>&lt;h2 id="ما-هي-لغة-go--what-is-go"&gt;ما هي لغة Go؟ — What is Go?&lt;/h2&gt;
&lt;p&gt;لغة &lt;strong&gt;Go&lt;/strong&gt; (وتُعرف أيضاً بـ &lt;strong&gt;Golang&lt;/strong&gt;) هي لغة برمجة مفتوحة المصدر طورتها شركة &lt;strong&gt;Google&lt;/strong&gt; عام 2009. صُممت Go لتكون بسيطة وسريعة وفعالة — خاصة لبناء الأنظمة الخلفية (backend systems) والخدمات السحابية.&lt;/p&gt;
&lt;h3 id="القصة-وراء-go"&gt;القصة وراء Go&lt;/h3&gt;
&lt;p&gt;في عام 2007، كان ثلاثة مهندسين في Google — &lt;strong&gt;روبرت غريسمر&lt;/strong&gt; (Robert Griesemer) و&lt;strong&gt;روب بايك&lt;/strong&gt; (Rob Pike) و&lt;strong&gt;كين تومبسون&lt;/strong&gt; (Ken Thompson) — يعانون من بطء الترجمة (compilation) في المشاريع الضخمة وتعقيد اللغات المتوفرة مثل C++ وJava.&lt;/p&gt;</description></item><item><title>أنماط الأخطاء المتقدمة</title><link>https://learn.azizwares.sa/go/06-errors/02-advanced-errors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/06-errors/02-advanced-errors/</guid><description>&lt;h2 id="أنماط-الأخطاء-المتقدمة--advanced-error-patterns"&gt;أنماط الأخطاء المتقدمة — Advanced Error Patterns&lt;/h2&gt;
&lt;p&gt;بعد فهم الأساسيات، حان وقت الأنماط المتقدمة. هذه الأنماط تُستخدم في المشاريع الكبيرة حيث تحتاج تصنيف الأخطاء والتعامل مع كل نوع بشكل مختلف.&lt;/p&gt;
&lt;h3 id="الأخطاء-الحارسة--sentinel-errors"&gt;الأخطاء الحارسة — Sentinel Errors&lt;/h3&gt;
&lt;p&gt;أخطاء مُعرّفة كمتغيرات على مستوى الحزمة، تُستخدم للمقارنة:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-534dcb78b1fb1f7dbac4ebfdfdd18327"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-534dcb78b1fb1f7dbac4ebfdfdd18327-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;errors&amp;#34;
 &amp;#34;fmt&amp;#34;
)

// أخطاء حارسة — Sentinel errors
var (
 ErrNotFound = errors.New(&amp;#34;غير موجود&amp;#34;)
 ErrUnauthorized = errors.New(&amp;#34;غير مصرح&amp;#34;)
 ErrForbidden = errors.New(&amp;#34;ممنوع الوصول&amp;#34;)
)

// محاكاة طلب — Simulate request
func getResource(id int, role string) (string, error) {
 if role == &amp;#34;&amp;#34; {
 return &amp;#34;&amp;#34;, ErrUnauthorized
 }
 if role != &amp;#34;admin&amp;#34; {
 return &amp;#34;&amp;#34;, ErrForbidden
 }
 if id &amp;gt; 100 {
 return &amp;#34;&amp;#34;, ErrNotFound
 }
 return fmt.Sprintf(&amp;#34;مورد #%d&amp;#34;, id), nil
}

func main() {
 cases := []struct {
 id int
 role string
 }{
 {1, &amp;#34;admin&amp;#34;},
 {1, &amp;#34;&amp;#34;},
 {1, &amp;#34;user&amp;#34;},
 {999, &amp;#34;admin&amp;#34;},
 }

 for _, c := range cases {
 result, err := getResource(c.id, c.role)
 switch {
 case err == nil:
 fmt.Printf(&amp;#34;✅ النتيجة: %s\n&amp;#34;, result)
 case errors.Is(err, ErrUnauthorized):
 fmt.Println(&amp;#34;🔐 يجب تسجيل الدخول أولاً&amp;#34;)
 case errors.Is(err, ErrForbidden):
 fmt.Println(&amp;#34;🚫 ليس لديك صلاحيات كافية&amp;#34;)
 case errors.Is(err, ErrNotFound):
 fmt.Println(&amp;#34;❓ المورد غير موجود&amp;#34;)
 default:
 fmt.Println(&amp;#34;❌ خطأ غير متوقع:&amp;#34;, err)
 }
 }
}&lt;/textarea&gt;
 &lt;div id="pg-534dcb78b1fb1f7dbac4ebfdfdd18327-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-534dcb78b1fb1f7dbac4ebfdfdd18327-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="أنواع-أخطاء-مخصصة--custom-error-types"&gt;أنواع أخطاء مخصصة — Custom Error Types&lt;/h3&gt;
&lt;p&gt;عندما تحتاج أن يحمل الخطأ بيانات إضافية:&lt;/p&gt;</description></item><item><title>أنواع البيانات</title><link>https://learn.azizwares.sa/go/02-basics/02-types/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/02-basics/02-types/</guid><description>&lt;h2 id="أنواع-البيانات--data-types"&gt;أنواع البيانات — Data Types&lt;/h2&gt;
&lt;p&gt;Go لغة &lt;strong&gt;ذات أنواع ثابتة&lt;/strong&gt; (statically typed) — كل متغير له نوع محدد لا يتغير. هذا يجعل الكود أكثر أماناً وأسرع في التنفيذ.&lt;/p&gt;
&lt;h3 id="الأنواع-الأساسية"&gt;الأنواع الأساسية&lt;/h3&gt;
&lt;h4 id="الأعداد-الصحيحة-integers"&gt;الأعداد الصحيحة (Integers)&lt;/h4&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;النوع&lt;/th&gt;
 &lt;th&gt;الحجم&lt;/th&gt;
 &lt;th&gt;المدى&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;int8&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;8 بت&lt;/td&gt;
 &lt;td&gt;-128 إلى 127&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;int16&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;16 بت&lt;/td&gt;
 &lt;td&gt;-32,768 إلى 32,767&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;int32&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;32 بت&lt;/td&gt;
 &lt;td&gt;±2 مليار&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;int64&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;64 بت&lt;/td&gt;
 &lt;td&gt;±9.2 كوينتيليون&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;int&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;32/64 بت&lt;/td&gt;
 &lt;td&gt;حسب النظام&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;uint&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;32/64 بت&lt;/td&gt;
 &lt;td&gt;أعداد موجبة فقط&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;byte&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;8 بت&lt;/td&gt;
 &lt;td&gt;اسم مستعار لـ uint8&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;في معظم الحالات، استخدم &lt;code&gt;int&lt;/code&gt; وخلاص — Go يختار الحجم المناسب.&lt;/p&gt;</description></item><item><title>الأنواع المعممة</title><link>https://learn.azizwares.sa/go/12-advanced/02-generics/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/12-advanced/02-generics/</guid><description>&lt;h2 id="الأنواع-المعممة--generics"&gt;الأنواع المعممة — Generics&lt;/h2&gt;
&lt;p&gt;قبل Go 1.18، إذا أردت دالة تعمل مع أنواع مختلفة كنت تحتاج إما &lt;code&gt;interface{}&lt;/code&gt; (تفقد أمان الأنواع) أو كتابة نفس الدالة لكل نوع. الأنواع المعممة (Generics) تحل هذه المشكلة بأناقة.&lt;/p&gt;
&lt;h3 id="المشكلة-بدون-generics"&gt;المشكلة بدون Generics&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-a15030a81eb8b2edc233dc4ed785812f"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-a15030a81eb8b2edc233dc4ed785812f-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// بدون generics — نحتاج دالة لكل نوع!
// Without generics — need a function per type!
func MaxInt(a, b int) int {
 if a &amp;gt; b { return a }
 return b
}

func MaxFloat(a, b float64) float64 {
 if a &amp;gt; b { return a }
 return b
}

func MaxString(a, b string) string {
 if a &amp;gt; b { return a }
 return b
}

func main() {
 fmt.Println(&amp;#34;أكبر int:&amp;#34;, MaxInt(3, 7))
 fmt.Println(&amp;#34;أكبر float:&amp;#34;, MaxFloat(3.14, 2.71))
 fmt.Println(&amp;#34;أكبر string:&amp;#34;, MaxString(&amp;#34;أحمد&amp;#34;, &amp;#34;زيد&amp;#34;))
 fmt.Println(&amp;#34;\n😤 ثلاث دوال لنفس المنطق!&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-a15030a81eb8b2edc233dc4ed785812f-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-a15030a81eb8b2edc233dc4ed785812f-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الحل-مع-generics"&gt;الحل مع Generics&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-1b23976eb3a4926700500648a7f7797f"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-1b23976eb3a4926700500648a7f7797f-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;cmp&amp;#34;
 &amp;#34;fmt&amp;#34;
)

// دالة معممة واحدة تعمل مع كل الأنواع القابلة للترتيب!
// One generic function works with all ordered types!
func Max[T cmp.Ordered](a, b T) T {
 if a &amp;gt; b {
 return a
 }
 return b
}

// دالة معممة أخرى — Another generic function
func Contains[T comparable](slice []T, target T) bool {
 for _, v := range slice {
 if v == target {
 return true
 }
 }
 return false
}

func main() {
 // نفس الدالة مع أنواع مختلفة — Same function, different types
 fmt.Println(&amp;#34;أكبر int:&amp;#34;, Max(3, 7))
 fmt.Println(&amp;#34;أكبر float:&amp;#34;, Max(3.14, 2.71))
 fmt.Println(&amp;#34;أكبر string:&amp;#34;, Max(&amp;#34;أحمد&amp;#34;, &amp;#34;زيد&amp;#34;))

 fmt.Println()

 // Contains مع أنواع مختلفة — Contains with different types
 nums := []int{1, 2, 3, 4, 5}
 fmt.Println(&amp;#34;يحتوي 3؟&amp;#34;, Contains(nums, 3))
 fmt.Println(&amp;#34;يحتوي 9؟&amp;#34;, Contains(nums, 9))

 names := []string{&amp;#34;أحمد&amp;#34;, &amp;#34;فاطمة&amp;#34;, &amp;#34;عمر&amp;#34;}
 fmt.Println(&amp;#34;يحتوي فاطمة؟&amp;#34;, Contains(names, &amp;#34;فاطمة&amp;#34;))
}&lt;/textarea&gt;
 &lt;div id="pg-1b23976eb3a4926700500648a7f7797f-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-1b23976eb3a4926700500648a7f7797f-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="القيود--constraints"&gt;القيود — Constraints&lt;/h3&gt;
&lt;p&gt;القيود تُحدد ما يمكن أن يكون عليه النوع المعمم:&lt;/p&gt;</description></item><item><title>الاختبارات الجدولية</title><link>https://learn.azizwares.sa/go/10-testing/02-table-tests/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/10-testing/02-table-tests/</guid><description>&lt;h2 id="الاختبارات-الجدولية--table-driven-tests"&gt;الاختبارات الجدولية — Table-Driven Tests&lt;/h2&gt;
&lt;p&gt;الاختبارات الجدولية هي &lt;strong&gt;نمط Go المميز&lt;/strong&gt; (idiomatic) — ستجده في كل مشروع Go احترافي، بما في ذلك الكود المصدري لـ Go نفسها. الفكرة: بدلاً من كتابة دالة اختبار لكل حالة، تضع كل الحالات في جدول وتتكرر عليها.&lt;/p&gt;
&lt;h3 id="لماذا-الاختبارات-الجدولية"&gt;لماذا الاختبارات الجدولية؟&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// ❌ بدون جدول — تكرار ممل&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;TestAdd1&lt;/span&gt;(t &lt;span style="color:#ff79c6"&gt;*&lt;/span&gt;testing.T) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;if&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;Add&lt;/span&gt;(&lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;2&lt;/span&gt;) &lt;span style="color:#ff79c6"&gt;!=&lt;/span&gt; &lt;span style="color:#bd93f9"&gt;3&lt;/span&gt; { t.&lt;span style="color:#50fa7b"&gt;Error&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;failed&amp;#34;&lt;/span&gt;) }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;TestAdd2&lt;/span&gt;(t &lt;span style="color:#ff79c6"&gt;*&lt;/span&gt;testing.T) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;if&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;Add&lt;/span&gt;(&lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;) &lt;span style="color:#ff79c6"&gt;!=&lt;/span&gt; &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt; { t.&lt;span style="color:#50fa7b"&gt;Error&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;failed&amp;#34;&lt;/span&gt;) }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;TestAdd3&lt;/span&gt;(t &lt;span style="color:#ff79c6"&gt;*&lt;/span&gt;testing.T) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;if&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;Add&lt;/span&gt;(&lt;span style="color:#ff79c6"&gt;-&lt;/span&gt;&lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;) &lt;span style="color:#ff79c6"&gt;!=&lt;/span&gt; &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt; { t.&lt;span style="color:#50fa7b"&gt;Error&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;failed&amp;#34;&lt;/span&gt;) }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// ✅ مع جدول — نظيف وقابل للتوسع&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;TestAdd&lt;/span&gt;(t &lt;span style="color:#ff79c6"&gt;*&lt;/span&gt;testing.T) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tests &lt;span style="color:#ff79c6"&gt;:=&lt;/span&gt; []&lt;span style="color:#8be9fd;font-style:italic"&gt;struct&lt;/span&gt;{ a, b, want &lt;span style="color:#8be9fd"&gt;int&lt;/span&gt; }{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;2&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;3&lt;/span&gt;},
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;},
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&lt;span style="color:#ff79c6"&gt;-&lt;/span&gt;&lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;, &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;},
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;for&lt;/span&gt; _, tt &lt;span style="color:#ff79c6"&gt;:=&lt;/span&gt; &lt;span style="color:#ff79c6"&gt;range&lt;/span&gt; tests {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; got &lt;span style="color:#ff79c6"&gt;:=&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;Add&lt;/span&gt;(tt.a, tt.b)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;if&lt;/span&gt; got &lt;span style="color:#ff79c6"&gt;!=&lt;/span&gt; tt.want {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; t.&lt;span style="color:#50fa7b"&gt;Errorf&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;Add(%d, %d) = %d, want %d&amp;#34;&lt;/span&gt;, tt.a, tt.b, got, tt.want)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="مثال-كامل"&gt;مثال كامل&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-ad6f8524873d4c70762231b36c13c220"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-ad6f8524873d4c70762231b36c13c220-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;strings&amp;#34;
 &amp;#34;unicode&amp;#34;
)

// الدوال المُختبرة — Functions under test
func IsPalindrome(s string) bool {
 s = strings.ToLower(s)
 runes := []rune(s)
 for i, j := 0, len(runes)-1; i &amp;lt; j; i, j = i&amp;#43;1, j-1 {
 if runes[i] != runes[j] {
 return false
 }
 }
 return true
}

func CountDigits(s string) int {
 count := 0
 for _, r := range s {
 if unicode.IsDigit(r) {
 count&amp;#43;&amp;#43;
 }
 }
 return count
}

func Truncate(s string, maxLen int) string {
 runes := []rune(s)
 if len(runes) &amp;lt;= maxLen {
 return s
 }
 if maxLen &amp;lt;= 3 {
 return string(runes[:maxLen])
 }
 return string(runes[:maxLen-3]) &amp;#43; &amp;#34;...&amp;#34;
}

func main() {
 // اختبار IsPalindrome — Test IsPalindrome
 fmt.Println(&amp;#34;=== IsPalindrome ===&amp;#34;)
 palindromeTests := []struct {
 name string
 input string
 want bool
 }{
 {&amp;#34;كلمة متماثلة&amp;#34;, &amp;#34;level&amp;#34;, true},
 {&amp;#34;كلمة عادية&amp;#34;, &amp;#34;hello&amp;#34;, false},
 {&amp;#34;حرف واحد&amp;#34;, &amp;#34;a&amp;#34;, true},
 {&amp;#34;فارغ&amp;#34;, &amp;#34;&amp;#34;, true},
 {&amp;#34;حالة مختلطة&amp;#34;, &amp;#34;Racecar&amp;#34;, true},
 }

 for _, tt := range palindromeTests {
 got := IsPalindrome(tt.input)
 status := &amp;#34;✅&amp;#34;
 if got != tt.want {
 status = &amp;#34;❌&amp;#34;
 }
 fmt.Printf(&amp;#34; %s %s: IsPalindrome(%q) = %v\n&amp;#34;, status, tt.name, tt.input, got)
 }

 // اختبار Truncate — Test Truncate
 fmt.Println(&amp;#34;\n=== Truncate ===&amp;#34;)
 truncateTests := []struct {
 name string
 input string
 maxLen int
 want string
 }{
 {&amp;#34;نص قصير&amp;#34;, &amp;#34;مرحبا&amp;#34;, 10, &amp;#34;مرحبا&amp;#34;},
 {&amp;#34;نص طويل&amp;#34;, &amp;#34;مرحبا بالعالم&amp;#34;, 8, &amp;#34;مرحب...&amp;#34;},
 {&amp;#34;الحد الأدنى&amp;#34;, &amp;#34;abcdef&amp;#34;, 3, &amp;#34;abc&amp;#34;},
 {&amp;#34;مساوي للحد&amp;#34;, &amp;#34;abc&amp;#34;, 3, &amp;#34;abc&amp;#34;},
 }

 for _, tt := range truncateTests {
 got := Truncate(tt.input, tt.maxLen)
 status := &amp;#34;✅&amp;#34;
 if got != tt.want {
 status = &amp;#34;❌&amp;#34;
 }
 fmt.Printf(&amp;#34; %s %s: Truncate(%q, %d) = %q\n&amp;#34;, status, tt.name, tt.input, tt.maxLen, got)
 }
}&lt;/textarea&gt;
 &lt;div id="pg-ad6f8524873d4c70762231b36c13c220-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-ad6f8524873d4c70762231b36c13c220-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الاختبارات-الفرعية--subtests-مع-trun"&gt;الاختبارات الفرعية — Subtests مع t.Run&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;t.Run&lt;/code&gt; يُنشئ اختبارات فرعية مُسمّاة — مفيد للتصفية والتنظيم:&lt;/p&gt;</description></item><item><title>التسجيل المهيكل</title><link>https://learn.azizwares.sa/go/13-production/02-logging/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/13-production/02-logging/</guid><description>&lt;h2 id="التسجيل-المهيكل--structured-logging"&gt;التسجيل المهيكل — Structured Logging&lt;/h2&gt;
&lt;p&gt;التسجيل العادي (&lt;code&gt;fmt.Println&lt;/code&gt; أو &lt;code&gt;log.Println&lt;/code&gt;) لا يكفي في الإنتاج. تحتاج تسجيلاً &lt;strong&gt;مهيكلاً&lt;/strong&gt; — بيانات مُنظّمة يمكن البحث فيها وتحليلها.&lt;/p&gt;
&lt;p&gt;منذ Go 1.21، المكتبة القياسية تحتوي &lt;code&gt;log/slog&lt;/code&gt; — تسجيل مهيكل احترافي بدون مكتبات خارجية.&lt;/p&gt;
&lt;h3 id="المشكلة-مع-التسجيل-العادي"&gt;المشكلة مع التسجيل العادي&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-cb9145e68730731be6d34e42f847cf81"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-cb9145e68730731be6d34e42f847cf81-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;log&amp;#34;
 &amp;#34;time&amp;#34;
)

func main() {
 // التسجيل العادي — Regular logging
 log.Println(&amp;#34;المستخدم سجّل دخوله&amp;#34;)
 log.Printf(&amp;#34;خطأ: فشل الاتصال بقاعدة البيانات (محاولة %d)&amp;#34;, 3)

 fmt.Println(&amp;#34;\n❌ المشاكل:&amp;#34;)
 fmt.Println(&amp;#34;1. لا مستويات (info vs error)&amp;#34;)
 fmt.Println(&amp;#34;2. لا بنية — نص حر يصعب تحليله&amp;#34;)
 fmt.Println(&amp;#34;3. لا بيانات إضافية مُنظّمة&amp;#34;)
 fmt.Println(&amp;#34;4. لا يعمل مع أدوات المراقبة (Grafana, ELK)&amp;#34;)

 fmt.Println(&amp;#34;\n✅ الحل: log/slog&amp;#34;)
 fmt.Println(`slog.Info(&amp;#34;المستخدم سجّل دخوله&amp;#34;,
 &amp;#34;user_id&amp;#34;, 42,
 &amp;#34;ip&amp;#34;, &amp;#34;192.168.1.1&amp;#34;,
 &amp;#34;duration_ms&amp;#34;, 150,
)`)
 fmt.Println(&amp;#34;\n→ يُنتج JSON أو نص مُنظّم يمكن تحليله&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-cb9145e68730731be6d34e42f847cf81-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-cb9145e68730731be6d34e42f847cf81-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="أساسيات-slog"&gt;أساسيات slog&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-af0ac2329342f21d347ba0a16186780c"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-af0ac2329342f21d347ba0a16186780c-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;log/slog&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 // المُسجّل الافتراضي — Default logger (text format)
 slog.Info(&amp;#34;بدء التطبيق&amp;#34;, &amp;#34;version&amp;#34;, &amp;#34;1.0.0&amp;#34;, &amp;#34;env&amp;#34;, &amp;#34;production&amp;#34;)
 slog.Warn(&amp;#34;الذاكرة منخفضة&amp;#34;, &amp;#34;available_mb&amp;#34;, 128)
 slog.Error(&amp;#34;فشل الاتصال&amp;#34;, &amp;#34;host&amp;#34;, &amp;#34;db.example.com&amp;#34;, &amp;#34;error&amp;#34;, &amp;#34;connection refused&amp;#34;)

 // تنسيق JSON — JSON format
 jsonLogger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
 jsonLogger.Info(&amp;#34;طلب HTTP&amp;#34;,
 &amp;#34;method&amp;#34;, &amp;#34;GET&amp;#34;,
 &amp;#34;path&amp;#34;, &amp;#34;/api/users&amp;#34;,
 &amp;#34;status&amp;#34;, 200,
 &amp;#34;duration_ms&amp;#34;, 45,
 )
}&lt;/textarea&gt;
 &lt;div id="pg-af0ac2329342f21d347ba0a16186780c-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-af0ac2329342f21d347ba0a16186780c-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="مستويات-التسجيل--log-levels"&gt;مستويات التسجيل — Log Levels&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-e61b9afd573e9bf7e34eb684abacccb6"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-e61b9afd573e9bf7e34eb684abacccb6-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;log/slog&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 // إعداد المستوى الأدنى — Set minimum level
 handler := slog.NewTextHandler(os.Stdout, &amp;amp;slog.HandlerOptions{
 Level: slog.LevelInfo, // تجاهل Debug — Ignore Debug
 })
 logger := slog.New(handler)

 logger.Debug(&amp;#34;تفاصيل تصحيح&amp;#34;, &amp;#34;key&amp;#34;, &amp;#34;value&amp;#34;) // ⬜ لن يظهر
 logger.Info(&amp;#34;معلومة عامة&amp;#34;, &amp;#34;user&amp;#34;, &amp;#34;أحمد&amp;#34;) // ✅ يظهر
 logger.Warn(&amp;#34;تحذير&amp;#34;, &amp;#34;disk_usage&amp;#34;, &amp;#34;85%&amp;#34;) // ✅ يظهر
 logger.Error(&amp;#34;خطأ!&amp;#34;, &amp;#34;err&amp;#34;, &amp;#34;timeout&amp;#34;) // ✅ يظهر

 slog.Info(&amp;#34;\nالمستويات:&amp;#34;, &amp;#34;Debug&amp;#34;, -4, &amp;#34;Info&amp;#34;, 0, &amp;#34;Warn&amp;#34;, 4, &amp;#34;Error&amp;#34;, 8)
}&lt;/textarea&gt;
 &lt;div id="pg-e61b9afd573e9bf7e34eb684abacccb6-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-e61b9afd573e9bf7e34eb684abacccb6-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="المجموعات-والسمات--groups--attributes"&gt;المجموعات والسمات — Groups &amp;amp; Attributes&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-3dea347665322ccdad26ffa428535b5f"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-3dea347665322ccdad26ffa428535b5f-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;log/slog&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))

 // مجموعة — Group
 logger.Info(&amp;#34;طلب HTTP&amp;#34;,
 slog.Group(&amp;#34;request&amp;#34;,
 slog.String(&amp;#34;method&amp;#34;, &amp;#34;POST&amp;#34;),
 slog.String(&amp;#34;path&amp;#34;, &amp;#34;/api/users&amp;#34;),
 slog.Int(&amp;#34;size&amp;#34;, 256),
 ),
 slog.Group(&amp;#34;response&amp;#34;,
 slog.Int(&amp;#34;status&amp;#34;, 201),
 slog.Int(&amp;#34;duration_ms&amp;#34;, 89),
 ),
 )

 // مُسجّل فرعي مع سمات ثابتة — Sub-logger with fixed attributes
 reqLogger := logger.With(&amp;#34;request_id&amp;#34;, &amp;#34;req-abc-123&amp;#34;, &amp;#34;user_id&amp;#34;, 42)
 reqLogger.Info(&amp;#34;بدء المعالجة&amp;#34;)
 reqLogger.Info(&amp;#34;استعلام قاعدة البيانات&amp;#34;, &amp;#34;query&amp;#34;, &amp;#34;SELECT *&amp;#34;, &amp;#34;rows&amp;#34;, 15)
 reqLogger.Info(&amp;#34;انتهاء المعالجة&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-3dea347665322ccdad26ffa428535b5f-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-3dea347665322ccdad26ffa428535b5f-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="معرف-الطلب--request-id--correlation-id"&gt;معرّف الطلب — Request ID / Correlation ID&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-c72ab6248900a62d03e75c455f2463b3"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-c72ab6248900a62d03e75c455f2463b3-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;math/rand&amp;#34;
 &amp;#34;time&amp;#34;
)

// توليد معرّف طلب — Generate request ID
func generateRequestID() string {
 const chars = &amp;#34;abcdefghijklmnopqrstuvwxyz0123456789&amp;#34;
 b := make([]byte, 8)
 for i := range b {
 b[i] = chars[rand.Intn(len(chars))]
 }
 return fmt.Sprintf(&amp;#34;req-%s&amp;#34;, string(b))
}

func main() {
 // محاكاة طلبات — Simulate requests
 for i := 0; i &amp;lt; 3; i&amp;#43;&amp;#43; {
 reqID := generateRequestID()
 start := time.Now()

 // كل رسالة تسجيل تحمل نفس المعرّف
 fmt.Printf(&amp;#34;[%s] → بدء الطلب\n&amp;#34;, reqID)
 time.Sleep(time.Duration(50&amp;#43;rand.Intn(100)) * time.Millisecond)
 fmt.Printf(&amp;#34;[%s] → استعلام قاعدة البيانات\n&amp;#34;, reqID)
 time.Sleep(time.Duration(20&amp;#43;rand.Intn(50)) * time.Millisecond)
 fmt.Printf(&amp;#34;[%s] → انتهى (%v)\n&amp;#34;, reqID, time.Since(start).Round(time.Millisecond))
 fmt.Println()
 }

 fmt.Println(&amp;#34;💡 المعرّف يسمح بتتبع طلب واحد عبر كل الطبقات&amp;#34;)
 fmt.Println(&amp;#34; في أدوات مثل Grafana/Kibana، ابحث بـ request_id&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-c72ab6248900a62d03e75c455f2463b3-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-c72ab6248900a62d03e75c455f2463b3-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="مسجل-مخصص-للإنتاج"&gt;مُسجّل مخصص للإنتاج&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-675e43a665339831a90a914ba2593715"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-675e43a665339831a90a914ba2593715-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;log/slog&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 // إعداد احترافي — Production setup
 var handler slog.Handler

 env := &amp;#34;production&amp;#34;

 if env == &amp;#34;production&amp;#34; {
 // JSON في الإنتاج — JSON in production
 handler = slog.NewJSONHandler(os.Stdout, &amp;amp;slog.HandlerOptions{
 Level: slog.LevelInfo,
 AddSource: true, // أضف اسم الملف ورقم السطر
 })
 } else {
 // نص مقروء في التطوير — Human-readable in development
 handler = slog.NewTextHandler(os.Stdout, &amp;amp;slog.HandlerOptions{
 Level: slog.LevelDebug,
 })
 }

 logger := slog.New(handler)
 slog.SetDefault(logger) // اجعله الافتراضي — Set as default

 slog.Info(&amp;#34;التطبيق بدأ&amp;#34;,
 &amp;#34;env&amp;#34;, env,
 &amp;#34;port&amp;#34;, 8080,
 &amp;#34;version&amp;#34;, &amp;#34;2.1.0&amp;#34;,
 )

 slog.Error(&amp;#34;مثال خطأ&amp;#34;,
 &amp;#34;error&amp;#34;, &amp;#34;connection timeout&amp;#34;,
 &amp;#34;host&amp;#34;, &amp;#34;db.example.com&amp;#34;,
 &amp;#34;retry_in&amp;#34;, &amp;#34;5s&amp;#34;,
 )
}&lt;/textarea&gt;
 &lt;div id="pg-675e43a665339831a90a914ba2593715-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-675e43a665339831a90a914ba2593715-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="مقارنة-مكتبات-التسجيل"&gt;مقارنة مكتبات التسجيل&lt;/h3&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;المكتبة&lt;/th&gt;
 &lt;th&gt;المميزات&lt;/th&gt;
 &lt;th&gt;متى تستخدمها&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;log/slog&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;مدمجة، مهيكلة، كافية&lt;/td&gt;
 &lt;td&gt;معظم المشاريع&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;zerolog&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;سريعة جداً، صفر تخصيص&lt;/td&gt;
 &lt;td&gt;أداء حرج&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;zap&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;من Uber، مرنة، سريعة&lt;/td&gt;
 &lt;td&gt;مشاريع كبيرة&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;



&lt;div class="challenge my-6 bg-surface-dark border-2 border-indigo/30 rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-gradient-to-l from-indigo/10 to-transparent border-b border-surface-dark-border"&gt;
 &lt;span class="text-indigo dark:text-indigo-light text-sm font-bold" dir="rtl"&gt;تحدي — Challenge&lt;/span&gt;
 &lt;div class="flex gap-2"&gt;
 
 &lt;button data-hint-toggle="ch-1696ba43213098a0190f1ea7795cc736-hint"
 class="text-gray-400 text-sm hover:text-gold transition"&gt;تلميح&lt;/button&gt;
 
 &lt;button data-challenge="ch-1696ba43213098a0190f1ea7795cc736" data-expected="INFO بدء الخادم port=8080 env=production\nERROR فشل الاتصال host=db.local error=timeout"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition"&gt;
 &amp;#9654; تحقق — Check
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;/div&gt;
 
 &lt;div id="ch-1696ba43213098a0190f1ea7795cc736-hint" class="hidden px-4 py-2 bg-indigo/5 text-gray-300 text-sm border-b border-surface-dark-border" dir="rtl"&gt;
 استخدم slog لتسجيل رسالتين — info و error
 &lt;/div&gt;
 
 &lt;textarea id="ch-1696ba43213098a0190f1ea7795cc736-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;log/slog&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 handler := slog.NewTextHandler(os.Stdout, &amp;amp;slog.HandlerOptions{
 Level: slog.LevelInfo,
 ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
 if a.Key == slog.TimeKey {
 return slog.Attr{}
 }
 return a
 },
 })
 logger := slog.New(handler)

 // سجّل رسالة Info مع port و env، ورسالة Error مع host و error
 // اكتب الكود هنا
 _ = logger
}&lt;/textarea&gt;
 &lt;div id="ch-1696ba43213098a0190f1ea7795cc736-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div id="ch-1696ba43213098a0190f1ea7795cc736-status" class="px-4 py-2 text-sm font-bold"&gt;&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="ch-1696ba43213098a0190f1ea7795cc736-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;</description></item><item><title>الخرائط</title><link>https://learn.azizwares.sa/go/03-data-structures/02-maps/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/03-data-structures/02-maps/</guid><description>&lt;h2 id="الخرائط--maps"&gt;الخرائط — Maps&lt;/h2&gt;
&lt;p&gt;الخريطة (Map) هي بنية بيانات تخزن أزواج &lt;strong&gt;مفتاح-قيمة&lt;/strong&gt; (key-value pairs). تُعرف في لغات أخرى بـ dictionary (Python) أو HashMap (Java) أو Object (JavaScript).&lt;/p&gt;
&lt;h3 id="إنشاء-خريطة"&gt;إنشاء خريطة&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-0215a7b8c9b27bcd7d71470e69b3f3c2"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-0215a7b8c9b27bcd7d71470e69b3f3c2-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 // الطريقة الأولى: make — Create with make
 ages := make(map[string]int)
 ages[&amp;#34;أحمد&amp;#34;] = 25
 ages[&amp;#34;سارة&amp;#34;] = 30
 ages[&amp;#34;عمر&amp;#34;] = 22
 
 fmt.Println(&amp;#34;الأعمار:&amp;#34;, ages)
 fmt.Println(&amp;#34;عمر أحمد:&amp;#34;, ages[&amp;#34;أحمد&amp;#34;])
 
 // الطريقة الثانية: القيمة المباشرة — Map literal
 capitals := map[string]string{
 &amp;#34;السعودية&amp;#34;: &amp;#34;الرياض&amp;#34;,
 &amp;#34;مصر&amp;#34;: &amp;#34;القاهرة&amp;#34;,
 &amp;#34;الأردن&amp;#34;: &amp;#34;عمّان&amp;#34;,
 &amp;#34;المغرب&amp;#34;: &amp;#34;الرباط&amp;#34;,
 }
 
 fmt.Println(&amp;#34;\nالعواصم:&amp;#34;, capitals)
 fmt.Println(&amp;#34;عاصمة السعودية:&amp;#34;, capitals[&amp;#34;السعودية&amp;#34;])
}&lt;/textarea&gt;
 &lt;div id="pg-0215a7b8c9b27bcd7d71470e69b3f3c2-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-0215a7b8c9b27bcd7d71470e69b3f3c2-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الوصول-والتحقق"&gt;الوصول والتحقق&lt;/h3&gt;
&lt;p&gt;عند الوصول لمفتاح غير موجود، Go يُرجع القيمة الصفرية. لذلك نستخدم صيغة القيمتين:&lt;/p&gt;</description></item><item><title>القنوات</title><link>https://learn.azizwares.sa/go/07-concurrency/02-channels/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/07-concurrency/02-channels/</guid><description>&lt;h2 id="القنوات--channels"&gt;القنوات — Channels&lt;/h2&gt;
&lt;p&gt;القنوات هي الطريقة الرسمية للتواصل بين goroutines في Go. تخيّلها كأنابيب: goroutine واحد يُرسل قيمة من طرف، و goroutine آخر يستقبلها من الطرف الآخر.&lt;/p&gt;
&lt;p&gt;القنوات تحل مشكلتين:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;التواصل&lt;/strong&gt; — تمرير البيانات بين goroutines&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;التزامن&lt;/strong&gt; — ضمان ترتيب العمليات&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="إنشاء-قناة-واستخدامها"&gt;إنشاء قناة واستخدامها&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-5bacc0c4e4cc8101133058eb085a355a"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-5bacc0c4e4cc8101133058eb085a355a-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 // إنشاء قناة — Create a channel
 ch := make(chan string)

 // إرسال من goroutine — Send from goroutine
 go func() {
 ch &amp;lt;- &amp;#34;السلام عليكم من goroutine!&amp;#34;
 }()

 // استقبال في main — Receive in main
 msg := &amp;lt;-ch
 fmt.Println(msg)
}&lt;/textarea&gt;
 &lt;div id="pg-5bacc0c4e4cc8101133058eb085a355a-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-5bacc0c4e4cc8101133058eb085a355a-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="كيف-تعمل-القناة-غير-المخزنة--unbuffered-channel"&gt;كيف تعمل القناة غير المُخزّنة — Unbuffered Channel&lt;/h3&gt;
&lt;p&gt;القناة غير المُخزّنة (الافتراضية) تعمل كنقطة تسليم مباشرة:&lt;/p&gt;</description></item><item><title>الواجهات</title><link>https://learn.azizwares.sa/go/05-interfaces/02-interfaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/05-interfaces/02-interfaces/</guid><description>&lt;h2 id="الواجهات--interfaces"&gt;الواجهات — Interfaces&lt;/h2&gt;
&lt;p&gt;الواجهات هي من أجمل مفاهيم Go وأكثرها أناقة. الفكرة بسيطة لكنها عميقة: &lt;strong&gt;الواجهة تُعرّف سلوكاً، لا بنية&lt;/strong&gt;. أي نوع يُنفّذ أساليب الواجهة يُحقق تلك الواجهة تلقائياً — بدون كلمة &lt;code&gt;implements&lt;/code&gt; ولا تسجيل صريح.&lt;/p&gt;
&lt;p&gt;هذا المبدأ يُعرف بـ &lt;strong&gt;التنفيذ الضمني&lt;/strong&gt; (Implicit Implementation)، وهو ما يجعل Go مختلفة عن أغلب اللغات.&lt;/p&gt;
&lt;h3 id="تعريف-واجهة"&gt;تعريف واجهة&lt;/h3&gt;
&lt;p&gt;الواجهة هي مجموعة من توقيعات الأساليب (method signatures):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// واجهة الشكل — Shape interface&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;type&lt;/span&gt; Shape &lt;span style="color:#8be9fd;font-style:italic"&gt;interface&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#50fa7b"&gt;Area&lt;/span&gt;() &lt;span style="color:#8be9fd"&gt;float64&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#50fa7b"&gt;Perimeter&lt;/span&gt;() &lt;span style="color:#8be9fd"&gt;float64&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;أي نوع يملك أسلوبي &lt;code&gt;Area()&lt;/code&gt; و &lt;code&gt;Perimeter()&lt;/code&gt; بنفس التوقيعات يُحقق واجهة &lt;code&gt;Shape&lt;/code&gt; — تلقائياً!&lt;/p&gt;</description></item><item><title>تثبيت Go</title><link>https://learn.azizwares.sa/go/01-introduction/02-install-go/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/01-introduction/02-install-go/</guid><description>&lt;h2 id="تثبيت-go--installing-go"&gt;تثبيت Go — Installing Go&lt;/h2&gt;
&lt;p&gt;قبل أن نبدأ البرمجة بجدية، نحتاج تثبيت Go على جهازك. العملية بسيطة جداً ولا تستغرق أكثر من ٥ دقائق.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ملاحظة:&lt;/strong&gt; يمكنك تنفيذ الأمثلة في هذه الدروس مباشرة عبر بيئة التشغيل المدمجة (Go Playground) بدون تثبيت أي شيء. لكن للمشاريع الحقيقية، ستحتاج التثبيت المحلي.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="الخطوة-١-تحميل-go"&gt;الخطوة ١: تحميل Go&lt;/h3&gt;
&lt;p&gt;اذهب إلى الموقع الرسمي: &lt;strong&gt;&lt;a href="https://go.dev/dl/"&gt;go.dev/dl&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;اختر النسخة المناسبة لنظام تشغيلك:&lt;/p&gt;
&lt;h3 id="على-windows"&gt;على Windows&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;حمّل ملف &lt;code&gt;.msi&lt;/code&gt; من صفحة التحميل&lt;/li&gt;
&lt;li&gt;شغّل الملف واتبع خطوات التثبيت (Next → Next → Install)&lt;/li&gt;
&lt;li&gt;Go سيُثبت تلقائياً في &lt;code&gt;C:\Go&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;المُثبّت يُضيف Go تلقائياً إلى &lt;code&gt;PATH&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;بعد التثبيت، افتح &lt;strong&gt;Command Prompt&lt;/strong&gt; أو &lt;strong&gt;PowerShell&lt;/strong&gt; وتحقق:&lt;/p&gt;</description></item><item><title>تصميم الحزم</title><link>https://learn.azizwares.sa/go/11-packages/02-packages/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/11-packages/02-packages/</guid><description>&lt;h2 id="تصميم-الحزم--package-design"&gt;تصميم الحزم — Package Design&lt;/h2&gt;
&lt;p&gt;الحزمة (Package) هي وحدة التنظيم الأساسية في Go. كل مجلد = حزمة واحدة. تصميم الحزم بشكل جيد هو ما يفرق بين مشروع Go مبتدئ ومحترف.&lt;/p&gt;
&lt;h3 id="التصدير--exported-vs-unexported"&gt;التصدير — Exported vs Unexported&lt;/h3&gt;
&lt;p&gt;في Go، &lt;strong&gt;الحرف الأول&lt;/strong&gt; يُحدد هل الشيء مرئي خارج الحزمة:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-31ab76cbe73f940e837a1e1423e8914c"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-31ab76cbe73f940e837a1e1423e8914c-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// مُصدّر — يبدأ بحرف كبير — Exported
type User struct {
 Name string // مُصدّر — Exported
 Email string // مُصدّر — Exported
 age int // خاص — Unexported
}

// مُصدّر — Exported function
func NewUser(name, email string, age int) *User {
 return &amp;amp;User{Name: name, Email: email, age: age}
}

// خاص — Unexported function
func validateEmail(email string) bool {
 for _, ch := range email {
 if ch == &amp;#39;@&amp;#39; {
 return true
 }
 }
 return false
}

// مُصدّر يستدعي خاص — Exported calls unexported
func (u *User) IsValid() bool {
 return u.Name != &amp;#34;&amp;#34; &amp;amp;&amp;amp; validateEmail(u.Email)
}

func main() {
 u := NewUser(&amp;#34;أحمد&amp;#34;, &amp;#34;ahmed@example.com&amp;#34;, 28)
 fmt.Printf(&amp;#34;الاسم: %s\n&amp;#34;, u.Name) // ✅ مُصدّر
 fmt.Printf(&amp;#34;البريد: %s\n&amp;#34;, u.Email) // ✅ مُصدّر
 // fmt.Println(u.age) // ❌ خاص (في حزمة أخرى)
 fmt.Printf(&amp;#34;صالح: %v\n&amp;#34;, u.IsValid())

 fmt.Println(&amp;#34;\n=== قواعد التصدير ===&amp;#34;)
 fmt.Println(&amp;#34;User → مُصدّر (حرف كبير)&amp;#34;)
 fmt.Println(&amp;#34;user → خاص (حرف صغير)&amp;#34;)
 fmt.Println(&amp;#34;NewUser → مُصدّر&amp;#34;)
 fmt.Println(&amp;#34;validate → خاص&amp;#34;)
 fmt.Println(&amp;#34;Name → حقل مُصدّر&amp;#34;)
 fmt.Println(&amp;#34;age → حقل خاص&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-31ab76cbe73f940e837a1e1423e8914c-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-31ab76cbe73f940e837a1e1423e8914c-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="مجلد-internal--الحزم-الداخلية"&gt;مجلد internal/ — الحزم الداخلية&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;internal/&lt;/code&gt; هو مجلد خاص في Go — الحزم داخله لا يمكن استيرادها إلا من الحزم الأم:&lt;/p&gt;</description></item><item><title>عمليات CRUD</title><link>https://learn.azizwares.sa/go/09-databases/02-crud/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/09-databases/02-crud/</guid><description>&lt;h2 id="عمليات-crud--crud-operations"&gt;عمليات CRUD — CRUD Operations&lt;/h2&gt;
&lt;p&gt;CRUD هي العمليات الأربع الأساسية لأي تطبيق يتعامل مع بيانات: الإنشاء (Create)، القراءة (Read)، التحديث (Update)، والحذف (Delete). سنتعلم كيف ننفذها في Go بطريقة آمنة واحترافية.&lt;/p&gt;
&lt;h3 id="بنية-المشروع-النموذجية"&gt;بنية المشروع النموذجية&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-f4c50d903b205f1c0f4c97c5c0d16583"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-f4c50d903b205f1c0f4c97c5c0d16583-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// نموذج المنتج — Product model
type Product struct {
 ID int
 Name string
 Price float64
 Category string
 InStock bool
}

// محاكاة قاعدة بيانات — Simulated database
var products = []Product{
 {ID: 1, Name: &amp;#34;لابتوب&amp;#34;, Price: 3500, Category: &amp;#34;إلكترونيات&amp;#34;, InStock: true},
 {ID: 2, Name: &amp;#34;كتاب Go&amp;#34;, Price: 75, Category: &amp;#34;كتب&amp;#34;, InStock: true},
 {ID: 3, Name: &amp;#34;سماعات&amp;#34;, Price: 250, Category: &amp;#34;إلكترونيات&amp;#34;, InStock: false},
}
var nextID = 4

// إنشاء — Create
func createProduct(name string, price float64, category string) Product {
 p := Product{ID: nextID, Name: name, Price: price, Category: category, InStock: true}
 nextID&amp;#43;&amp;#43;
 products = append(products, p)
 return p
}

// قراءة واحد — Read one
func getProduct(id int) (Product, bool) {
 for _, p := range products {
 if p.ID == id {
 return p, true
 }
 }
 return Product{}, false
}

// تحديث — Update
func updateProduct(id int, name string, price float64) bool {
 for i := range products {
 if products[i].ID == id {
 products[i].Name = name
 products[i].Price = price
 return true
 }
 }
 return false
}

// حذف — Delete
func deleteProduct(id int) bool {
 for i, p := range products {
 if p.ID == id {
 products = append(products[:i], products[i&amp;#43;1:]...)
 return true
 }
 }
 return false
}

func main() {
 // Create
 newProduct := createProduct(&amp;#34;ماوس&amp;#34;, 120, &amp;#34;إلكترونيات&amp;#34;)
 fmt.Printf(&amp;#34;✅ إنشاء: %s (ID: %d)\n&amp;#34;, newProduct.Name, newProduct.ID)

 // Read
 p, found := getProduct(2)
 if found {
 fmt.Printf(&amp;#34;📖 قراءة: %s — %.0f ريال\n&amp;#34;, p.Name, p.Price)
 }

 // Update
 if updateProduct(2, &amp;#34;كتاب Go المتقدم&amp;#34;, 95) {
 fmt.Println(&amp;#34;✏️ تحديث: تم تحديث المنتج 2&amp;#34;)
 }

 // Delete
 if deleteProduct(3) {
 fmt.Println(&amp;#34;🗑️ حذف: تم حذف المنتج 3&amp;#34;)
 }

 // قائمة المنتجات — List products
 fmt.Println(&amp;#34;\nالمنتجات النهائية:&amp;#34;)
 for _, p := range products {
 fmt.Printf(&amp;#34; #%d: %s — %.0f ريال\n&amp;#34;, p.ID, p.Name, p.Price)
 }
}&lt;/textarea&gt;
 &lt;div id="pg-f4c50d903b205f1c0f4c97c5c0d16583-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-f4c50d903b205f1c0f4c97c5c0d16583-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="العبارات-المعدة--prepared-statements"&gt;العبارات المُعدّة — Prepared Statements&lt;/h3&gt;
&lt;p&gt;العبارات المُعدّة تُحسّن الأداء عند تكرار نفس الاستعلام مع قيم مختلفة:&lt;/p&gt;</description></item><item><title>قراءة وكتابة الملفات</title><link>https://learn.azizwares.sa/go/04-practical/02-file-io/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/04-practical/02-file-io/</guid><description>&lt;h2 id="قراءة-وكتابة-الملفات--file-io"&gt;قراءة وكتابة الملفات — File I/O&lt;/h2&gt;
&lt;p&gt;التعامل مع الملفات مهارة أساسية في أي لغة. Go توفر حزماً قوية وبسيطة: &lt;code&gt;os&lt;/code&gt; للعمليات الأساسية، &lt;code&gt;bufio&lt;/code&gt; للقراءة المُخزنة، و&lt;code&gt;io&lt;/code&gt; لعمليات الإدخال/الإخراج العامة.&lt;/p&gt;
&lt;h3 id="قراءة-ملف-كاملا"&gt;قراءة ملف كاملاً&lt;/h3&gt;
&lt;p&gt;أبسط طريقة لقراءة ملف:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-0c2730c0b0115e54621eb05456d16240"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-0c2730c0b0115e54621eb05456d16240-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;os&amp;#34;
)

func main() {
 // سنُحاكي قراءة ملف — Simulating file read
 // في الواقع: data, err := os.ReadFile(&amp;#34;config.txt&amp;#34;)
 
 // لنكتب ملف أولاً ثم نقرأه — Write then read
 content := []byte(&amp;#34;بسم الله الرحمن الرحيم\nهذا ملف تجريبي\nسطر ثالث&amp;#34;)
 
 // كتابة — Write file
 err := os.WriteFile(&amp;#34;/tmp/test.txt&amp;#34;, content, 0644)
 if err != nil {
 fmt.Println(&amp;#34;خطأ في الكتابة:&amp;#34;, err)
 return
 }
 fmt.Println(&amp;#34;✅ كُتب الملف بنجاح&amp;#34;)
 
 // قراءة — Read file
 data, err := os.ReadFile(&amp;#34;/tmp/test.txt&amp;#34;)
 if err != nil {
 fmt.Println(&amp;#34;خطأ في القراءة:&amp;#34;, err)
 return
 }
 
 fmt.Println(&amp;#34;\n📄 محتوى الملف:&amp;#34;)
 fmt.Println(string(data))
 
 // حذف — Cleanup
 os.Remove(&amp;#34;/tmp/test.txt&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-0c2730c0b0115e54621eb05456d16240-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-0c2730c0b0115e54621eb05456d16240-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="القراءة-سطرا-بسطر"&gt;القراءة سطراً بسطر&lt;/h3&gt;
&lt;p&gt;للملفات الكبيرة، القراءة سطراً بسطر أفضل من تحميل الملف كاملاً:&lt;/p&gt;</description></item><item><title>واجهات JSON</title><link>https://learn.azizwares.sa/go/08-http/02-json-api/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/08-http/02-json-api/</guid><description>&lt;h2 id="واجهات-json--json-apis"&gt;واجهات JSON — JSON APIs&lt;/h2&gt;
&lt;p&gt;معظم التطبيقات الحديثة تتواصل عبر JSON. Go تأتي مع حزمة &lt;code&gt;encoding/json&lt;/code&gt; قوية تُحوّل بين Go structs و JSON بسلاسة.&lt;/p&gt;
&lt;h3 id="تشفير-json--marshal"&gt;تشفير JSON — Marshal&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-805d13cba34d8c0a32608842290d4a60"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-805d13cba34d8c0a32608842290d4a60-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;encoding/json&amp;#34;
 &amp;#34;fmt&amp;#34;
)

// مستخدم — User
type User struct {
 ID int `json:&amp;#34;id&amp;#34;`
 Name string `json:&amp;#34;name&amp;#34;`
 Email string `json:&amp;#34;email&amp;#34;`
 Age int `json:&amp;#34;age,omitempty&amp;#34;` // يُحذف إذا صفر — Omit if zero
 Password string `json:&amp;#34;-&amp;#34;` // لا يظهر في JSON أبداً — Never in JSON
 Tags []string `json:&amp;#34;tags,omitempty&amp;#34;`
}

func main() {
 user := User{
 ID: 1,
 Name: &amp;#34;أحمد&amp;#34;,
 Email: &amp;#34;ahmed@example.com&amp;#34;,
 Age: 28,
 Password: &amp;#34;secret123&amp;#34;,
 Tags: []string{&amp;#34;مطور&amp;#34;, &amp;#34;Go&amp;#34;},
 }

 // تحويل إلى JSON — Convert to JSON
 data, err := json.Marshal(user)
 if err != nil {
 fmt.Println(&amp;#34;خطأ:&amp;#34;, err)
 return
 }
 fmt.Println(&amp;#34;JSON:&amp;#34;, string(data))

 // تنسيق جميل — Pretty print
 pretty, _ := json.MarshalIndent(user, &amp;#34;&amp;#34;, &amp;#34; &amp;#34;)
 fmt.Println(&amp;#34;\nJSON مُنسّق:&amp;#34;)
 fmt.Println(string(pretty))

 // بدون عمر — Without age (omitempty)
 user2 := User{ID: 2, Name: &amp;#34;فاطمة&amp;#34;, Email: &amp;#34;fatima@example.com&amp;#34;}
 data2, _ := json.Marshal(user2)
 fmt.Println(&amp;#34;\nبدون عمر:&amp;#34;, string(data2))
}&lt;/textarea&gt;
 &lt;div id="pg-805d13cba34d8c0a32608842290d4a60-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-805d13cba34d8c0a32608842290d4a60-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="فك-تشفير-json--unmarshal"&gt;فك تشفير JSON — Unmarshal&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-47f01893f16873085c6c00ea16266e96"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-47f01893f16873085c6c00ea16266e96-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;encoding/json&amp;#34;
 &amp;#34;fmt&amp;#34;
)

type Product struct {
 ID int `json:&amp;#34;id&amp;#34;`
 Name string `json:&amp;#34;name&amp;#34;`
 Price float64 `json:&amp;#34;price&amp;#34;`
 InStock bool `json:&amp;#34;in_stock&amp;#34;`
}

func main() {
 // JSON → struct
 jsonStr := `{&amp;#34;id&amp;#34;: 1, &amp;#34;name&amp;#34;: &amp;#34;كتاب Go&amp;#34;, &amp;#34;price&amp;#34;: 49.99, &amp;#34;in_stock&amp;#34;: true}`

 var product Product
 err := json.Unmarshal([]byte(jsonStr), &amp;amp;product)
 if err != nil {
 fmt.Println(&amp;#34;خطأ:&amp;#34;, err)
 return
 }
 fmt.Printf(&amp;#34;المنتج: %&amp;#43;v\n&amp;#34;, product)
 fmt.Printf(&amp;#34;الاسم: %s، السعر: %.2f\n&amp;#34;, product.Name, product.Price)

 // مصفوفة JSON — JSON array
 jsonArray := `[
 {&amp;#34;id&amp;#34;: 1, &amp;#34;name&amp;#34;: &amp;#34;قلم&amp;#34;, &amp;#34;price&amp;#34;: 5.0, &amp;#34;in_stock&amp;#34;: true},
 {&amp;#34;id&amp;#34;: 2, &amp;#34;name&amp;#34;: &amp;#34;دفتر&amp;#34;, &amp;#34;price&amp;#34;: 12.5, &amp;#34;in_stock&amp;#34;: false}
 ]`

 var products []Product
 json.Unmarshal([]byte(jsonArray), &amp;amp;products)
 for _, p := range products {
 status := &amp;#34;متوفر ✅&amp;#34;
 if !p.InStock {
 status = &amp;#34;غير متوفر ❌&amp;#34;
 }
 fmt.Printf(&amp;#34; %s — %.2f ريال — %s\n&amp;#34;, p.Name, p.Price, status)
 }

 // JSON ديناميكي — Dynamic JSON
 dynamic := `{&amp;#34;key&amp;#34;: &amp;#34;value&amp;#34;, &amp;#34;number&amp;#34;: 42, &amp;#34;nested&amp;#34;: {&amp;#34;a&amp;#34;: 1}}`
 var result map[string]interface{}
 json.Unmarshal([]byte(dynamic), &amp;amp;result)
 fmt.Printf(&amp;#34;\nJSON ديناميكي: %v\n&amp;#34;, result)
}&lt;/textarea&gt;
 &lt;div id="pg-47f01893f16873085c6c00ea16266e96-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-47f01893f16873085c6c00ea16266e96-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="بناء-rest-api-كامل"&gt;بناء REST API كامل&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-1557cf0027458f48523885ebb66c1107"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-1557cf0027458f48523885ebb66c1107-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;encoding/json&amp;#34;
 &amp;#34;fmt&amp;#34;
 &amp;#34;net/http&amp;#34;
 &amp;#34;strings&amp;#34;
)

// نموذج المهمة — Task model
type Task struct {
 ID int `json:&amp;#34;id&amp;#34;`
 Title string `json:&amp;#34;title&amp;#34;`
 Done bool `json:&amp;#34;done&amp;#34;`
}

// استجابة API — API response
type APIResponse struct {
 Success bool `json:&amp;#34;success&amp;#34;`
 Data interface{} `json:&amp;#34;data,omitempty&amp;#34;`
 Error string `json:&amp;#34;error,omitempty&amp;#34;`
}

// مخزن بسيط — Simple store
var tasks = []Task{
 {ID: 1, Title: &amp;#34;تعلم Go&amp;#34;, Done: true},
 {ID: 2, Title: &amp;#34;بناء API&amp;#34;, Done: false},
 {ID: 3, Title: &amp;#34;نشر المشروع&amp;#34;, Done: false},
}

// دالة مساعدة للـ JSON — JSON helper
func writeJSON(w http.ResponseWriter, status int, data interface{}) {
 w.Header().Set(&amp;#34;Content-Type&amp;#34;, &amp;#34;application/json; charset=utf-8&amp;#34;)
 w.WriteHeader(status)
 json.NewEncoder(w).Encode(data)
}

// معالج المهام — Task handler
func taskHandler(w http.ResponseWriter, r *http.Request) {
 switch r.Method {
 case &amp;#34;GET&amp;#34;:
 writeJSON(w, http.StatusOK, APIResponse{
 Success: true,
 Data: tasks,
 })
 case &amp;#34;POST&amp;#34;:
 var newTask Task
 if err := json.NewDecoder(r.Body).Decode(&amp;amp;newTask); err != nil {
 writeJSON(w, http.StatusBadRequest, APIResponse{
 Success: false,
 Error: &amp;#34;بيانات غير صالحة&amp;#34;,
 })
 return
 }
 newTask.ID = len(tasks) &amp;#43; 1
 tasks = append(tasks, newTask)
 writeJSON(w, http.StatusCreated, APIResponse{
 Success: true,
 Data: newTask,
 })
 default:
 writeJSON(w, http.StatusMethodNotAllowed, APIResponse{
 Success: false,
 Error: &amp;#34;أسلوب غير مسموح&amp;#34;,
 })
 }
}

func main() {
 // محاكاة الاستجابة — Simulate response
 resp := APIResponse{
 Success: true,
 Data: tasks,
 }
 data, _ := json.MarshalIndent(resp, &amp;#34;&amp;#34;, &amp;#34; &amp;#34;)
 fmt.Println(&amp;#34;GET /api/tasks:&amp;#34;)
 fmt.Println(string(data))

 // محاكاة إنشاء مهمة — Simulate creating task
 newTaskJSON := `{&amp;#34;title&amp;#34;: &amp;#34;كتابة اختبارات&amp;#34;, &amp;#34;done&amp;#34;: false}`
 var newTask Task
 json.NewDecoder(strings.NewReader(newTaskJSON)).Decode(&amp;amp;newTask)
 newTask.ID = len(tasks) &amp;#43; 1
 tasks = append(tasks, newTask)

 fmt.Printf(&amp;#34;\nPOST /api/tasks → أُنشئت مهمة %d: %s\n&amp;#34;, newTask.ID, newTask.Title)
 fmt.Printf(&amp;#34;المجموع الآن: %d مهام\n&amp;#34;, len(tasks))

 _ = taskHandler // مُعرّف للاستخدام مع http.HandleFunc
}&lt;/textarea&gt;
 &lt;div id="pg-1557cf0027458f48523885ebb66c1107-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-1557cf0027458f48523885ebb66c1107-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="وسوم-json-المهمة--json-tags"&gt;وسوم JSON المهمة — JSON Tags&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;type&lt;/span&gt; Example &lt;span style="color:#8be9fd;font-style:italic"&gt;struct&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Field1 &lt;span style="color:#8be9fd"&gt;string&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;`json:&amp;#34;field_1&amp;#34;`&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// اسم مخصص&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Field2 &lt;span style="color:#8be9fd"&gt;int&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;`json:&amp;#34;field_2,omitempty&amp;#34;`&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// حذف إذا صفر&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Field3 &lt;span style="color:#8be9fd"&gt;bool&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;`json:&amp;#34;-&amp;#34;`&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// تجاهل تماماً&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Field4 &lt;span style="color:#8be9fd"&gt;string&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;`json:&amp;#34;field_4,string&amp;#34;`&lt;/span&gt; &lt;span style="color:#6272a4"&gt;// تشفير كنص&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="jsonencoder-vs-jsonmarshal"&gt;json.Encoder vs json.Marshal&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// Marshal — يُنتج []byte — عندما تحتاج النتيجة كنص&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data, err &lt;span style="color:#ff79c6"&gt;:=&lt;/span&gt; json.&lt;span style="color:#50fa7b"&gt;Marshal&lt;/span&gt;(obj)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// Encoder — يكتب مباشرة لـ io.Writer — أفضل للـ HTTP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;json.&lt;span style="color:#50fa7b"&gt;NewEncoder&lt;/span&gt;(w).&lt;span style="color:#50fa7b"&gt;Encode&lt;/span&gt;(obj)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6272a4"&gt;// Decoder — يقرأ من io.Reader — أفضل لقراءة الطلب&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;json.&lt;span style="color:#50fa7b"&gt;NewDecoder&lt;/span&gt;(r.Body).&lt;span style="color:#50fa7b"&gt;Decode&lt;/span&gt;(&lt;span style="color:#ff79c6"&gt;&amp;amp;&lt;/span&gt;obj)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;div class="challenge my-6 bg-surface-dark border-2 border-indigo/30 rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-gradient-to-l from-indigo/10 to-transparent border-b border-surface-dark-border"&gt;
 &lt;span class="text-indigo dark:text-indigo-light text-sm font-bold" dir="rtl"&gt;تحدي — Challenge&lt;/span&gt;
 &lt;div class="flex gap-2"&gt;
 
 &lt;button data-hint-toggle="ch-e95f64a9d0f0eecd9e750f52c9c39136-hint"
 class="text-gray-400 text-sm hover:text-gold transition"&gt;تلميح&lt;/button&gt;
 
 &lt;button data-challenge="ch-e95f64a9d0f0eecd9e750f52c9c39136" data-expected="المنتج: كتاب Go (49.99 ريال) - متوفر"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition"&gt;
 &amp;#9654; تحقق — Check
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;/div&gt;
 
 &lt;div id="ch-e95f64a9d0f0eecd9e750f52c9c39136-hint" class="hidden px-4 py-2 bg-indigo/5 text-gray-300 text-sm border-b border-surface-dark-border" dir="rtl"&gt;
 فك تشفير JSON لمنتج واطبعه بتنسيق محدد
 &lt;/div&gt;
 
 &lt;textarea id="ch-e95f64a9d0f0eecd9e750f52c9c39136-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;encoding/json&amp;#34;
 &amp;#34;fmt&amp;#34;
)

type Product struct {
 Name string `json:&amp;#34;name&amp;#34;`
 Price float64 `json:&amp;#34;price&amp;#34;`
 InStock bool `json:&amp;#34;in_stock&amp;#34;`
}

func main() {
 data := `{&amp;#34;name&amp;#34;: &amp;#34;كتاب Go&amp;#34;, &amp;#34;price&amp;#34;: 49.99, &amp;#34;in_stock&amp;#34;: true}`

 var p Product
 // فك تشفير JSON إلى p باستخدام json.Unmarshal — اكتب الكود هنا

 status := &amp;#34;متوفر&amp;#34;
 if !p.InStock {
 status = &amp;#34;غير متوفر&amp;#34;
 }
 fmt.Printf(&amp;#34;المنتج: %s (%.2f ريال) - %s\n&amp;#34;, p.Name, p.Price, status)
}&lt;/textarea&gt;
 &lt;div id="ch-e95f64a9d0f0eecd9e750f52c9c39136-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div id="ch-e95f64a9d0f0eecd9e750f52c9c39136-status" class="px-4 py-2 text-sm font-bold"&gt;&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="ch-e95f64a9d0f0eecd9e750f52c9c39136-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;</description></item><item><title>أنماط التصميم</title><link>https://learn.azizwares.sa/go/12-advanced/03-patterns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/12-advanced/03-patterns/</guid><description>&lt;h2 id="أنماط-التصميم--design-patterns"&gt;أنماط التصميم — Design Patterns&lt;/h2&gt;
&lt;p&gt;Go ليست لغة OOP تقليدية، لكنها تملك أنماط تصميم خاصة بها نشأت من الممارسة. هذه الأنماط ستجدها في كل مشروع Go احترافي.&lt;/p&gt;
&lt;h3 id="نمط-الخيارات-الوظيفية--functional-options"&gt;نمط الخيارات الوظيفية — Functional Options&lt;/h3&gt;
&lt;p&gt;هذا النمط يحل مشكلة الدوال التي تقبل إعدادات كثيرة اختيارية:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-ffdae990f822b12b856ae442863eda21"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-ffdae990f822b12b856ae442863eda21-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// الخادم — Server
type Server struct {
 Host string
 Port int
 MaxConns int
 ReadTimeout int // بالثواني
 WriteTimeout int
 TLS bool
}

// نوع الخيار — Option type
type Option func(*Server)

// خيارات — Options
func WithPort(port int) Option {
 return func(s *Server) { s.Port = port }
}

func WithMaxConns(n int) Option {
 return func(s *Server) { s.MaxConns = n }
}

func WithTLS(enabled bool) Option {
 return func(s *Server) { s.TLS = enabled }
}

func WithTimeouts(read, write int) Option {
 return func(s *Server) {
 s.ReadTimeout = read
 s.WriteTimeout = write
 }
}

// المُنشئ — Constructor
func NewServer(host string, opts ...Option) *Server {
 // القيم الافتراضية — Defaults
 s := &amp;amp;Server{
 Host: host,
 Port: 8080,
 MaxConns: 100,
 ReadTimeout: 30,
 WriteTimeout: 30,
 TLS: false,
 }

 // تطبيق الخيارات — Apply options
 for _, opt := range opts {
 opt(s)
 }

 return s
}

func main() {
 // خادم بالإعدادات الافتراضية — Server with defaults
 s1 := NewServer(&amp;#34;localhost&amp;#34;)
 fmt.Printf(&amp;#34;افتراضي: %s:%d (TLS: %v, MaxConns: %d)\n&amp;#34;,
 s1.Host, s1.Port, s1.TLS, s1.MaxConns)

 // خادم مخصص — Custom server
 s2 := NewServer(&amp;#34;api.example.com&amp;#34;,
 WithPort(443),
 WithTLS(true),
 WithMaxConns(1000),
 WithTimeouts(60, 60),
 )
 fmt.Printf(&amp;#34;مخصص: %s:%d (TLS: %v, MaxConns: %d)\n&amp;#34;,
 s2.Host, s2.Port, s2.TLS, s2.MaxConns)
}&lt;/textarea&gt;
 &lt;div id="pg-ffdae990f822b12b856ae442863eda21-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-ffdae990f822b12b856ae442863eda21-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;لماذا هذا النمط مميز:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>أنماط قواعد البيانات</title><link>https://learn.azizwares.sa/go/09-databases/03-patterns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/09-databases/03-patterns/</guid><description>&lt;h2 id="أنماط-قواعد-البيانات--database-patterns"&gt;أنماط قواعد البيانات — Database Patterns&lt;/h2&gt;
&lt;p&gt;بعد تعلم الأساسيات، حان وقت الأنماط الاحترافية التي تُنظّم كودك وتجعله قابلاً للصيانة والاختبار.&lt;/p&gt;
&lt;h3 id="نمط-repository"&gt;نمط Repository&lt;/h3&gt;
&lt;p&gt;يفصل منطق الوصول للبيانات عن منطق الأعمال. بدلاً من كتابة SQL في كل مكان، تُغلّفه في طبقة واحدة:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-8fe5eb76a57ac7dd20141d192e24c5f1"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-8fe5eb76a57ac7dd20141d192e24c5f1-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;errors&amp;#34;
 &amp;#34;fmt&amp;#34;
)

// النموذج — Model
type User struct {
 ID int
 Name string
 Email string
 Age int
}

// واجهة Repository — Repository interface
type UserRepository interface {
 Create(user *User) error
 GetByID(id int) (*User, error)
 GetAll() ([]User, error)
 Update(user *User) error
 Delete(id int) error
}

// تنفيذ في الذاكرة — In-memory implementation
type InMemoryUserRepo struct {
 users map[int]*User
 nextID int
}

func NewInMemoryUserRepo() *InMemoryUserRepo {
 return &amp;amp;InMemoryUserRepo{
 users: make(map[int]*User),
 nextID: 1,
 }
}

var ErrUserNotFound = errors.New(&amp;#34;المستخدم غير موجود&amp;#34;)

func (r *InMemoryUserRepo) Create(user *User) error {
 user.ID = r.nextID
 r.nextID&amp;#43;&amp;#43;
 r.users[user.ID] = user
 return nil
}

func (r *InMemoryUserRepo) GetByID(id int) (*User, error) {
 user, ok := r.users[id]
 if !ok {
 return nil, ErrUserNotFound
 }
 return user, nil
}

func (r *InMemoryUserRepo) GetAll() ([]User, error) {
 result := make([]User, 0, len(r.users))
 for _, u := range r.users {
 result = append(result, *u)
 }
 return result, nil
}

func (r *InMemoryUserRepo) Update(user *User) error {
 if _, ok := r.users[user.ID]; !ok {
 return ErrUserNotFound
 }
 r.users[user.ID] = user
 return nil
}

func (r *InMemoryUserRepo) Delete(id int) error {
 if _, ok := r.users[id]; !ok {
 return ErrUserNotFound
 }
 delete(r.users, id)
 return nil
}

// خدمة الأعمال — Business service
type UserService struct {
 repo UserRepository
}

func (s *UserService) RegisterUser(name, email string, age int) (*User, error) {
 if name == &amp;#34;&amp;#34; || email == &amp;#34;&amp;#34; {
 return nil, fmt.Errorf(&amp;#34;الاسم والبريد مطلوبان&amp;#34;)
 }
 user := &amp;amp;User{Name: name, Email: email, Age: age}
 if err := s.repo.Create(user); err != nil {
 return nil, fmt.Errorf(&amp;#34;فشل التسجيل: %w&amp;#34;, err)
 }
 return user, nil
}

func main() {
 // إنشاء الطبقات — Create layers
 repo := NewInMemoryUserRepo()
 service := &amp;amp;UserService{repo: repo}

 // استخدام الخدمة — Use service
 u1, _ := service.RegisterUser(&amp;#34;أحمد&amp;#34;, &amp;#34;ahmed@example.com&amp;#34;, 28)
 u2, _ := service.RegisterUser(&amp;#34;فاطمة&amp;#34;, &amp;#34;fatima@example.com&amp;#34;, 24)
 fmt.Printf(&amp;#34;تسجيل: %s (ID: %d)\n&amp;#34;, u1.Name, u1.ID)
 fmt.Printf(&amp;#34;تسجيل: %s (ID: %d)\n&amp;#34;, u2.Name, u2.ID)

 // قراءة — Read
 user, err := repo.GetByID(1)
 if err != nil {
 fmt.Println(&amp;#34;خطأ:&amp;#34;, err)
 } else {
 fmt.Printf(&amp;#34;البحث: %s — %s\n&amp;#34;, user.Name, user.Email)
 }

 // قائمة — List
 all, _ := repo.GetAll()
 fmt.Printf(&amp;#34;المجموع: %d مستخدمين\n&amp;#34;, len(all))
}&lt;/textarea&gt;
 &lt;div id="pg-8fe5eb76a57ac7dd20141d192e24c5f1-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-8fe5eb76a57ac7dd20141d192e24c5f1-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;لماذا Repository مهم:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>أول برنامج — Hello World</title><link>https://learn.azizwares.sa/go/01-introduction/03-hello-world/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/01-introduction/03-hello-world/</guid><description>&lt;h2 id="أول-برنامج--hello-world"&gt;أول برنامج — Hello World&lt;/h2&gt;
&lt;p&gt;كل مبرمج يبدأ رحلته بـ &amp;ldquo;Hello World&amp;rdquo; — وهذا التقليد بدأ مع لغة C عام 1978. لكن في AzLearn، سنكتب &amp;ldquo;مرحباً بالعالم&amp;rdquo; 🐹&lt;/p&gt;
&lt;h3 id="البرنامج-الكامل"&gt;البرنامج الكامل&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-30eded54b6983ca51945c6929859d7b7"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-30eded54b6983ca51945c6929859d7b7-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// البرنامج الرئيسي — Main program
func main() {
 fmt.Println(&amp;#34;مرحباً بالعالم! 🌍&amp;#34;)
 fmt.Println(&amp;#34;Hello, World!&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-30eded54b6983ca51945c6929859d7b7-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-30eded54b6983ca51945c6929859d7b7-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;لنفهم كل سطر بالتفصيل:&lt;/p&gt;</description></item><item><title>اختبارات متقدمة</title><link>https://learn.azizwares.sa/go/10-testing/03-advanced/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/10-testing/03-advanced/</guid><description>&lt;h2 id="اختبارات-متقدمة--advanced-testing"&gt;اختبارات متقدمة — Advanced Testing&lt;/h2&gt;
&lt;p&gt;بعد إتقان الأساسيات والاختبارات الجدولية، ننتقل لأدوات أقوى: قياس الأداء، محاكاة الاعتماديات، واختبار خوادم HTTP.&lt;/p&gt;
&lt;h3 id="اختبارات-الأداء--benchmarks"&gt;اختبارات الأداء — Benchmarks&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-e77a5dd2ec0c7694c1db06a07b15ebc9"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-e77a5dd2ec0c7694c1db06a07b15ebc9-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(`// ملف: string_test.go
package main

import (
 &amp;#34;strings&amp;#34;
 &amp;#34;testing&amp;#34;
)

// اختبار أداء الربط — Benchmark concatenation
func BenchmarkConcat(b *testing.B) {
 for i := 0; i &amp;lt; b.N; i&amp;#43;&amp;#43; {
 s := &amp;#34;&amp;#34;
 for j := 0; j &amp;lt; 100; j&amp;#43;&amp;#43; {
 s &amp;#43;= &amp;#34;x&amp;#34;
 }
 }
}

// اختبار أداء Builder — Benchmark Builder
func BenchmarkBuilder(b *testing.B) {
 for i := 0; i &amp;lt; b.N; i&amp;#43;&amp;#43; {
 var sb strings.Builder
 for j := 0; j &amp;lt; 100; j&amp;#43;&amp;#43; {
 sb.WriteString(&amp;#34;x&amp;#34;)
 }
 _ = sb.String()
 }
}`)

 fmt.Println(&amp;#34;\n=== تشغيل Benchmarks ===&amp;#34;)
 fmt.Println(&amp;#34;go test -bench=. → كل الـ benchmarks&amp;#34;)
 fmt.Println(&amp;#34;go test -bench=BenchmarkConcat&amp;#34;)
 fmt.Println(&amp;#34;go test -bench=. -benchmem → مع إحصائيات الذاكرة&amp;#34;)
 fmt.Println(&amp;#34;go test -bench=. -count=5 → 5 مرات للدقة&amp;#34;)

 fmt.Println(&amp;#34;\n=== مثال الناتج ===&amp;#34;)
 fmt.Println(&amp;#34;BenchmarkConcat-8 10000 115000 ns/op 25208 B/op 99 allocs/op&amp;#34;)
 fmt.Println(&amp;#34;BenchmarkBuilder-8 200000 5200 ns/op 512 B/op 1 allocs/op&amp;#34;)

 fmt.Println(&amp;#34;\n💡 Builder أسرع 22 مرة وأقل ذاكرة 49 مرة!&amp;#34;)
 fmt.Println(&amp;#34;b.N يُحدد تلقائياً — Go يختار العدد المناسب&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-e77a5dd2ec0c7694c1db06a07b15ebc9-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-e77a5dd2ec0c7694c1db06a07b15ebc9-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الأنواع-الوهمية--mocks--stubs"&gt;الأنواع الوهمية — Mocks &amp;amp; Stubs&lt;/h3&gt;
&lt;p&gt;في Go، الواجهات تجعل المحاكاة سهلة جداً — لا تحتاج مكتبة خاصة:&lt;/p&gt;</description></item><item><title>الدوال</title><link>https://learn.azizwares.sa/go/02-basics/03-functions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/02-basics/03-functions/</guid><description>&lt;h2 id="الدوال--functions"&gt;الدوال — Functions&lt;/h2&gt;
&lt;p&gt;الدوال هي اللبنة الأساسية لتنظيم الكود في Go. كل برنامج Go يبدأ بدالة &lt;code&gt;main&lt;/code&gt;، لكنك ستكتب عشرات الدوال في أي مشروع حقيقي.&lt;/p&gt;
&lt;h3 id="تعريف-دالة-بسيطة"&gt;تعريف دالة بسيطة&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;greet&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; fmt.&lt;span style="color:#50fa7b"&gt;Println&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;مرحباً!&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="دالة-مع-معاملات-parameters"&gt;دالة مع معاملات (Parameters)&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;greet&lt;/span&gt;(name &lt;span style="color:#8be9fd"&gt;string&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; fmt.&lt;span style="color:#50fa7b"&gt;Println&lt;/span&gt;(&lt;span style="color:#f1fa8c"&gt;&amp;#34;مرحباً يا&amp;#34;&lt;/span&gt;, name)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;إذا كانت المعاملات من نفس النوع، يمكنك اختصار الكتابة:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#8be9fd;font-style:italic"&gt;func&lt;/span&gt; &lt;span style="color:#50fa7b"&gt;add&lt;/span&gt;(a, b &lt;span style="color:#8be9fd"&gt;int&lt;/span&gt;) &lt;span style="color:#8be9fd"&gt;int&lt;/span&gt; { &lt;span style="color:#6272a4"&gt;// a و b كلاهما int&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;return&lt;/span&gt; a &lt;span style="color:#ff79c6"&gt;+&lt;/span&gt; b
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="دالة-مع-قيمة-مرجعة-return-value"&gt;دالة مع قيمة مُرجعة (Return Value)&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-d996287d7d99ba6aa6227ffee0311dab"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-d996287d7d99ba6aa6227ffee0311dab-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// دالة الجمع — Add function
func add(a, b int) int {
 return a &amp;#43; b
}

// دالة التحية — Greet function
func greet(name string) string {
 return &amp;#34;مرحباً يا &amp;#34; &amp;#43; name &amp;#43; &amp;#34;! 👋&amp;#34;
}

// دالة المساحة — Area of rectangle
func area(width, height float64) float64 {
 return width * height
}

func main() {
 result := add(15, 27)
 fmt.Println(&amp;#34;15 &amp;#43; 27 =&amp;#34;, result)
 
 msg := greet(&amp;#34;عزيز&amp;#34;)
 fmt.Println(msg)
 
 a := area(5.5, 3.2)
 fmt.Printf(&amp;#34;المساحة: %.2f\n&amp;#34;, a)
}&lt;/textarea&gt;
 &lt;div id="pg-d996287d7d99ba6aa6227ffee0311dab-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-d996287d7d99ba6aa6227ffee0311dab-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الإرجاع-المتعدد-multiple-returns"&gt;الإرجاع المتعدد (Multiple Returns)&lt;/h3&gt;
&lt;p&gt;هذه من أقوى ميزات Go — الدالة يمكنها إرجاع &lt;strong&gt;عدة قيم&lt;/strong&gt;. يُستخدم كثيراً لإرجاع نتيجة + خطأ:&lt;/p&gt;</description></item><item><title>النشر والإنتاج</title><link>https://learn.azizwares.sa/go/13-production/03-deployment/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/13-production/03-deployment/</guid><description>&lt;h2 id="النشر-والإنتاج--deployment"&gt;النشر والإنتاج — Deployment&lt;/h2&gt;
&lt;p&gt;هذا الدرس الأخير يجمع كل شيء — كيف تأخذ تطبيق Go من جهازك إلى الإنتاج بشكل موثوق ومُراقب.&lt;/p&gt;
&lt;h3 id="cicd-مع-github-actions"&gt;CI/CD مع GitHub Actions&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-66030b0bdbfdc2b2000c665a66007da1"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-66030b0bdbfdc2b2000c665a66007da1-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(`# .github/workflows/deploy.yml
name: Build &amp;amp; Deploy

on:
 push:
 branches: [main]
 pull_request:
 branches: [main]

jobs:
 test:
 runs-on: ubuntu-latest
 steps:
 - uses: actions/checkout@v4
 - uses: actions/setup-go@v5
 with:
 go-version: &amp;#39;1.22&amp;#39;

 - name: تنزيل الاعتماديات
 run: go mod download

 - name: الاختبارات مع كشف السباق
 run: go test -race -v ./...

 - name: التغطية
 run: go test -coverprofile=coverage.out ./...

 - name: الفحص الثابت
 uses: golangci/golangci-lint-action@v4

 build:
 needs: test
 runs-on: ubuntu-latest
 steps:
 - uses: actions/checkout@v4
 - name: بناء صورة Docker
 run: docker build -t myapp:${{ github.sha }} .

 - name: نشر
 if: github.ref == &amp;#39;refs/heads/main&amp;#39;
 run: |
 docker tag myapp:${{ github.sha }} registry.example.com/myapp:latest
 docker push registry.example.com/myapp:latest`)
}&lt;/textarea&gt;
 &lt;div id="pg-66030b0bdbfdc2b2000c665a66007da1-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-66030b0bdbfdc2b2000c665a66007da1-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="makefile-للمشروع"&gt;Makefile للمشروع&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-6a4e249134d14086150f79bbb82e71de"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-6a4e249134d14086150f79bbb82e71de-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 fmt.Println(`# Makefile
.PHONY: build test run lint clean

# البناء — Build
build:
	CGO_ENABLED=0 go build -ldflags=&amp;#34;-s -w&amp;#34; -o bin/server ./cmd/server

# الاختبارات — Test
test:
	go test -race -cover ./...

# التشغيل — Run
run:
	go run ./cmd/server

# الفحص الثابت — Lint
lint:
	golangci-lint run

# التنظيف — Clean
clean:
	rm -rf bin/

# Docker
docker-build:
	docker build -t myapp .

docker-run:
	docker compose up -d`)

 fmt.Println(&amp;#34;\n=== الاستخدام ===&amp;#34;)
 fmt.Println(&amp;#34;make build → بناء الملف التنفيذي&amp;#34;)
 fmt.Println(&amp;#34;make test → تشغيل الاختبارات&amp;#34;)
 fmt.Println(&amp;#34;make lint → فحص الكود&amp;#34;)
 fmt.Println(&amp;#34;make run → تشغيل محلي&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-6a4e249134d14086150f79bbb82e71de-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-6a4e249134d14086150f79bbb82e71de-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الإيقاف-اللطيف--graceful-shutdown"&gt;الإيقاف اللطيف — Graceful Shutdown&lt;/h3&gt;
&lt;p&gt;عند إيقاف الخادم، يجب إنهاء الطلبات الحالية قبل الإغلاق:&lt;/p&gt;</description></item><item><title>الهياكل</title><link>https://learn.azizwares.sa/go/03-data-structures/03-structs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/03-data-structures/03-structs/</guid><description>&lt;h2 id="الهياكل--structs"&gt;الهياكل — Structs&lt;/h2&gt;
&lt;p&gt;الهيكل (Struct) هو نوع بيانات مركّب يجمع عدة حقول (fields) في وحدة واحدة. فكّر فيه كـ &amp;ldquo;class&amp;rdquo; مبسّطة — Go لا تحتوي على classes بالمعنى التقليدي.&lt;/p&gt;
&lt;h3 id="تعريف-هيكل"&gt;تعريف هيكل&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-ad19bba2fd4f3300731854de370c1a01"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-ad19bba2fd4f3300731854de370c1a01-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// تعريف هيكل — Define a struct
type Person struct {
 Name string
 Age int
 City string
 IsAdmin bool
}

func main() {
 // إنشاء — Create
 p1 := Person{
 Name: &amp;#34;عزيز&amp;#34;,
 Age: 25,
 City: &amp;#34;المدينة المنورة&amp;#34;,
 IsAdmin: true,
 }
 fmt.Println(&amp;#34;الشخص:&amp;#34;, p1)
 
 // الوصول للحقول — Access fields
 fmt.Println(&amp;#34;الاسم:&amp;#34;, p1.Name)
 fmt.Println(&amp;#34;العمر:&amp;#34;, p1.Age)
 
 // تعديل — Modify
 p1.Age = 26
 fmt.Println(&amp;#34;العمر الجديد:&amp;#34;, p1.Age)
 
 // إنشاء بالترتيب — Positional (غير مُستحسن)
 p2 := Person{&amp;#34;سارة&amp;#34;, 30, &amp;#34;الرياض&amp;#34;, false}
 fmt.Println(&amp;#34;شخص ٢:&amp;#34;, p2)
 
 // إنشاء جزئي — Partial (باقي الحقول = قيم صفرية)
 p3 := Person{Name: &amp;#34;أحمد&amp;#34;}
 fmt.Printf(&amp;#34;شخص ٣: %&amp;#43;v\n&amp;#34;, p3) // %&amp;#43;v يعرض أسماء الحقول
}&lt;/textarea&gt;
 &lt;div id="pg-ad19bba2fd4f3300731854de370c1a01-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-ad19bba2fd4f3300731854de370c1a01-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="الطرق-methods"&gt;الطرق (Methods)&lt;/h3&gt;
&lt;p&gt;الطرق هي دوال مرتبطة بنوع معين. تُعرّف بإضافة &lt;strong&gt;مستقبِل&lt;/strong&gt; (receiver) قبل اسم الدالة:&lt;/p&gt;</description></item><item><title>الواجهات الشائعة</title><link>https://learn.azizwares.sa/go/05-interfaces/03-common-interfaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/05-interfaces/03-common-interfaces/</guid><description>&lt;h2 id="الواجهات-الشائعة--common-interfaces"&gt;الواجهات الشائعة — Common Interfaces&lt;/h2&gt;
&lt;p&gt;Go مبنية على واجهات صغيرة ومحددة. المكتبة القياسية مليئة بواجهات تُستخدم في كل مكان. فهم هذه الواجهات يجعلك تكتب كوداً أكثر احترافية ومتوافقاً مع النظام البيئي لـ Go.&lt;/p&gt;
&lt;h3 id="واجهة-fmtstringer"&gt;واجهة fmt.Stringer&lt;/h3&gt;
&lt;p&gt;أي نوع يُنفّذ &lt;code&gt;String() string&lt;/code&gt; يتحكم في كيفية طباعته:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-826ad1167e5cf0b51c8c0827d5002117"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-826ad1167e5cf0b51c8c0827d5002117-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

// حساب بنكي — Bank account
type Account struct {
 Owner string
 Balance float64
 Currency string
}

// تنفيذ Stringer — Implement Stringer
func (a Account) String() string {
 return fmt.Sprintf(&amp;#34;💰 %s: %.2f %s&amp;#34;, a.Owner, a.Balance, a.Currency)
}

// لون — Color
type Color struct {
 R, G, B uint8
}

func (c Color) String() string {
 return fmt.Sprintf(&amp;#34;#%02X%02X%02X&amp;#34;, c.R, c.G, c.B)
}

func main() {
 acc := Account{Owner: &amp;#34;أحمد&amp;#34;, Balance: 5420.50, Currency: &amp;#34;ريال&amp;#34;}
 fmt.Println(acc) // يستدعي String() تلقائياً

 red := Color{R: 255, G: 0, B: 0}
 fmt.Println(&amp;#34;الأحمر:&amp;#34;, red)

 gold := Color{R: 212, G: 168, B: 83}
 fmt.Println(&amp;#34;الذهبي:&amp;#34;, gold)
}&lt;/textarea&gt;
 &lt;div id="pg-826ad1167e5cf0b51c8c0827d5002117-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-826ad1167e5cf0b51c8c0827d5002117-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="واجهة-error"&gt;واجهة error&lt;/h3&gt;
&lt;p&gt;واجهة &lt;code&gt;error&lt;/code&gt; هي أبسط واجهة في Go — أسلوب واحد فقط:&lt;/p&gt;</description></item><item><title>الوسيط</title><link>https://learn.azizwares.sa/go/08-http/03-middleware/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/08-http/03-middleware/</guid><description>&lt;h2 id="الوسيط--middleware"&gt;الوسيط — Middleware&lt;/h2&gt;
&lt;p&gt;الوسيط (Middleware) هو نمط يسمح لك بتنفيذ كود &lt;strong&gt;قبل وبعد&lt;/strong&gt; المعالج الفعلي — مثل التسجيل، المصادقة، ضغط البيانات، وغيرها. في Go، الوسيط هو ببساطة دالة تأخذ &lt;code&gt;http.Handler&lt;/code&gt; وتُرجع &lt;code&gt;http.Handler&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="مفهوم-الوسيط"&gt;مفهوم الوسيط&lt;/h3&gt;
&lt;p&gt;الفكرة بسيطة: كل طلب يمر عبر سلسلة من الدوال قبل أن يصل للمعالج النهائي:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;الطلب → [تسجيل] → [مصادقة] → [CORS] → المعالج → الاستجابة
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="كتابة-وسيط-بسيط"&gt;كتابة وسيط بسيط&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-f529cec8ea9cf15a56855ac75d685dd7"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-f529cec8ea9cf15a56855ac75d685dd7-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;net/http&amp;#34;
 &amp;#34;time&amp;#34;
)

// وسيط التسجيل — Logging middleware
func loggingMiddleware(next http.Handler) http.Handler {
 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 start := time.Now()

 // تنفيذ المعالج التالي — Execute next handler
 next.ServeHTTP(w, r)

 // تسجيل بعد الانتهاء — Log after completion
 duration := time.Since(start)
 fmt.Printf(&amp;#34;[%s] %s %s — %v\n&amp;#34;,
 time.Now().Format(&amp;#34;15:04:05&amp;#34;),
 r.Method,
 r.URL.Path,
 duration,
 )
 })
}

// وسيط الترويسات — Headers middleware
func headersMiddleware(next http.Handler) http.Handler {
 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 w.Header().Set(&amp;#34;X-Server&amp;#34;, &amp;#34;AzLearn/1.0&amp;#34;)
 w.Header().Set(&amp;#34;Content-Type&amp;#34;, &amp;#34;application/json; charset=utf-8&amp;#34;)
 next.ServeHTTP(w, r)
 })
}

// المعالج الفعلي — Actual handler
func helloHandler(w http.ResponseWriter, r *http.Request) {
 fmt.Fprint(w, `{&amp;#34;message&amp;#34;: &amp;#34;أهلاً!&amp;#34;}`)
}

func main() {
 // سلسلة الوسيط — Middleware chain
 handler := loggingMiddleware(
 headersMiddleware(
 http.HandlerFunc(helloHandler),
 ),
 )

 fmt.Println(&amp;#34;سلسلة الوسيط:&amp;#34;)
 fmt.Println(&amp;#34;الطلب → loggingMiddleware → headersMiddleware → helloHandler&amp;#34;)
 fmt.Println(&amp;#34;\nهذا هو نمط الوسيط في Go!&amp;#34;)

 _ = handler
}&lt;/textarea&gt;
 &lt;div id="pg-f529cec8ea9cf15a56855ac75d685dd7-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-f529cec8ea9cf15a56855ac75d685dd7-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="وسيط-المصادقة--authentication-middleware"&gt;وسيط المصادقة — Authentication Middleware&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-4ec3de83c6d116d31011196e008d2101"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-4ec3de83c6d116d31011196e008d2101-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;net/http&amp;#34;
 &amp;#34;strings&amp;#34;
)

// وسيط المصادقة — Auth middleware
func authMiddleware(next http.Handler) http.Handler {
 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 token := r.Header.Get(&amp;#34;Authorization&amp;#34;)

 if token == &amp;#34;&amp;#34; {
 http.Error(w, `{&amp;#34;error&amp;#34;: &amp;#34;مطلوب رمز مصادقة&amp;#34;}`, http.StatusUnauthorized)
 return // مهم! لا تكمل — Important! Don&amp;#39;t continue
 }

 if !strings.HasPrefix(token, &amp;#34;Bearer &amp;#34;) {
 http.Error(w, `{&amp;#34;error&amp;#34;: &amp;#34;تنسيق رمز غير صالح&amp;#34;}`, http.StatusUnauthorized)
 return
 }

 // تحقق من الرمز — Validate token
 actualToken := strings.TrimPrefix(token, &amp;#34;Bearer &amp;#34;)
 if actualToken != &amp;#34;valid-token-123&amp;#34; {
 http.Error(w, `{&amp;#34;error&amp;#34;: &amp;#34;رمز منتهي أو غير صالح&amp;#34;}`, http.StatusForbidden)
 return
 }

 // المصادقة ناجحة — Auth successful
 next.ServeHTTP(w, r)
 })
}

func main() {
 // محاكاة فحص المصادقة — Simulate auth check
 tokens := []string{
 &amp;#34;&amp;#34;,
 &amp;#34;InvalidFormat&amp;#34;,
 &amp;#34;Bearer wrong-token&amp;#34;,
 &amp;#34;Bearer valid-token-123&amp;#34;,
 }

 for _, token := range tokens {
 if token == &amp;#34;&amp;#34; {
 fmt.Println(&amp;#34;❌ بدون رمز → 401 غير مصرح&amp;#34;)
 } else if !strings.HasPrefix(token, &amp;#34;Bearer &amp;#34;) {
 fmt.Println(&amp;#34;❌ تنسيق خاطئ → 401 غير مصرح&amp;#34;)
 } else if strings.TrimPrefix(token, &amp;#34;Bearer &amp;#34;) != &amp;#34;valid-token-123&amp;#34; {
 fmt.Println(&amp;#34;❌ رمز خاطئ → 403 ممنوع&amp;#34;)
 } else {
 fmt.Println(&amp;#34;✅ مصادقة ناجحة → 200&amp;#34;)
 }
 }
}&lt;/textarea&gt;
 &lt;div id="pg-4ec3de83c6d116d31011196e008d2101-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-4ec3de83c6d116d31011196e008d2101-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="وسيط-cors"&gt;وسيط CORS&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-730b921cede2ea3e3473ded79e8a90ea"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-730b921cede2ea3e3473ded79e8a90ea-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;net/http&amp;#34;
)

// وسيط CORS — CORS middleware
func corsMiddleware(next http.Handler) http.Handler {
 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 // ضبط ترويسات CORS — Set CORS headers
 w.Header().Set(&amp;#34;Access-Control-Allow-Origin&amp;#34;, &amp;#34;*&amp;#34;)
 w.Header().Set(&amp;#34;Access-Control-Allow-Methods&amp;#34;, &amp;#34;GET, POST, PUT, DELETE, OPTIONS&amp;#34;)
 w.Header().Set(&amp;#34;Access-Control-Allow-Headers&amp;#34;, &amp;#34;Content-Type, Authorization&amp;#34;)
 w.Header().Set(&amp;#34;Access-Control-Max-Age&amp;#34;, &amp;#34;86400&amp;#34;)

 // طلبات OPTIONS (preflight) — Handle preflight
 if r.Method == &amp;#34;OPTIONS&amp;#34; {
 w.WriteHeader(http.StatusNoContent) // 204
 return
 }

 next.ServeHTTP(w, r)
 })
}

func main() {
 fmt.Println(&amp;#34;ترويسات CORS:&amp;#34;)
 fmt.Println(&amp;#34;Access-Control-Allow-Origin: *&amp;#34;)
 fmt.Println(&amp;#34;Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS&amp;#34;)
 fmt.Println(&amp;#34;Access-Control-Allow-Headers: Content-Type, Authorization&amp;#34;)
 fmt.Println(&amp;#34;\nطلب OPTIONS → 204 No Content (بدون جسم)&amp;#34;)
 fmt.Println(&amp;#34;طلب GET/POST → يكمل للمعالج التالي مع ترويسات CORS&amp;#34;)

 _ = corsMiddleware
}&lt;/textarea&gt;
 &lt;div id="pg-730b921cede2ea3e3473ded79e8a90ea-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-730b921cede2ea3e3473ded79e8a90ea-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="سلسلة-الوسيط--middleware-chaining"&gt;سلسلة الوسيط — Middleware Chaining&lt;/h3&gt;
&lt;p&gt;بدلاً من التداخل العميق، يمكنك إنشاء دالة مساعدة:&lt;/p&gt;</description></item><item><title>عبارة Select</title><link>https://learn.azizwares.sa/go/07-concurrency/03-select/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/07-concurrency/03-select/</guid><description>&lt;h2 id="عبارة-select--select-statement"&gt;عبارة Select — Select Statement&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;select&lt;/code&gt; هي مثل &lt;code&gt;switch&lt;/code&gt; لكن للقنوات. تنتظر عدة عمليات قنوات وتُنفّذ أول واحدة تكون جاهزة. هذا يجعلك تتعامل مع عدة مصادر بيانات متزامنة بأناقة.&lt;/p&gt;
&lt;h3 id="select-الأساسية"&gt;select الأساسية&lt;/h3&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-085886b6ac318c3efc1c5e1576c2256b"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-085886b6ac318c3efc1c5e1576c2256b-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;time&amp;#34;
)

func main() {
 ch1 := make(chan string)
 ch2 := make(chan string)

 // goroutine بطيء — Slow goroutine
 go func() {
 time.Sleep(200 * time.Millisecond)
 ch1 &amp;lt;- &amp;#34;من القناة الأولى&amp;#34;
 }()

 // goroutine سريع — Fast goroutine
 go func() {
 time.Sleep(100 * time.Millisecond)
 ch2 &amp;lt;- &amp;#34;من القناة الثانية&amp;#34;
 }()

 // select تختار أول قناة جاهزة
 // select picks the first ready channel
 for i := 0; i &amp;lt; 2; i&amp;#43;&amp;#43; {
 select {
 case msg := &amp;lt;-ch1:
 fmt.Println(&amp;#34;ch1:&amp;#34;, msg)
 case msg := &amp;lt;-ch2:
 fmt.Println(&amp;#34;ch2:&amp;#34;, msg)
 }
 }
}&lt;/textarea&gt;
 &lt;div id="pg-085886b6ac318c3efc1c5e1576c2256b-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-085886b6ac318c3efc1c5e1576c2256b-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;h3 id="المهل-الزمنية--timeouts"&gt;المهل الزمنية — Timeouts&lt;/h3&gt;
&lt;p&gt;من أهم استخدامات &lt;code&gt;select&lt;/code&gt; — تحديد وقت أقصى للانتظار:&lt;/p&gt;</description></item><item><title>التحكم في التدفق</title><link>https://learn.azizwares.sa/go/02-basics/04-control-flow/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/02-basics/04-control-flow/</guid><description>&lt;h2 id="التحكم-في-التدفق--control-flow"&gt;التحكم في التدفق — Control Flow&lt;/h2&gt;
&lt;p&gt;Go تمتلك أدوات تحكم بسيطة وقوية. لا يوجد &lt;code&gt;while&lt;/code&gt; ولا &lt;code&gt;do-while&lt;/code&gt; — حلقة &lt;code&gt;for&lt;/code&gt; تغطي كل شيء!&lt;/p&gt;
&lt;h3 id="if--else"&gt;if / else&lt;/h3&gt;
&lt;p&gt;لا تحتاج أقواساً حول الشرط (على عكس C وJava):&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-e550a069c36b541e4a2b03e75b23a801"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-e550a069c36b541e4a2b03e75b23a801-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import &amp;#34;fmt&amp;#34;

func main() {
 age := 20
 
 // شرط بسيط — Simple condition
 if age &amp;gt;= 18 {
 fmt.Println(&amp;#34;بالغ ✅&amp;#34;)
 } else {
 fmt.Println(&amp;#34;قاصر ❌&amp;#34;)
 }
 
 // if-else if-else
 score := 85
 if score &amp;gt;= 90 {
 fmt.Println(&amp;#34;ممتاز 🌟&amp;#34;)
 } else if score &amp;gt;= 80 {
 fmt.Println(&amp;#34;جيد جداً 👍&amp;#34;)
 } else if score &amp;gt;= 70 {
 fmt.Println(&amp;#34;جيد&amp;#34;)
 } else {
 fmt.Println(&amp;#34;يحتاج تحسين&amp;#34;)
 }
 
 // if مع تعريف متغير — if with init statement (ميزة مميزة!)
 if x := 10 * 2; x &amp;gt; 15 {
 fmt.Println(&amp;#34;x =&amp;#34;, x, &amp;#34;وهو أكبر من 15&amp;#34;)
 }
 // x غير موجود هنا — x is not accessible here
}&lt;/textarea&gt;
 &lt;div id="pg-e550a069c36b541e4a2b03e75b23a801-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-e550a069c36b541e4a2b03e75b23a801-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ميزة Go الفريدة:&lt;/strong&gt; يمكنك تعريف متغير داخل &lt;code&gt;if&lt;/code&gt; — نطاقه محدود بالشرط فقط. هذا يُستخدم كثيراً مع معالجة الأخطاء.&lt;/p&gt;</description></item><item><title>حزمة sync</title><link>https://learn.azizwares.sa/go/07-concurrency/04-sync/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learn.azizwares.sa/go/07-concurrency/04-sync/</guid><description>&lt;h2 id="حزمة-sync--sync-package"&gt;حزمة sync — Sync Package&lt;/h2&gt;
&lt;p&gt;القنوات هي الطريقة المفضلة للتزامن في Go، لكن أحياناً تحتاج أدوات منخفضة المستوى. حزمة &lt;code&gt;sync&lt;/code&gt; توفر أقفال (mutexes) ومجموعات انتظار وغيرها.&lt;/p&gt;
&lt;h3 id="سباق-البيانات--race-condition"&gt;سباق البيانات — Race Condition&lt;/h3&gt;
&lt;p&gt;قبل أن نتعلم الحلول، لنفهم المشكلة:&lt;/p&gt;

&lt;div class="playground my-6 bg-surface-dark border border-surface-dark-border rounded-xl overflow-hidden" dir="ltr"&gt;
 &lt;div class="flex items-center justify-between px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border"&gt;
 &lt;span class="text-gray-400 text-sm font-mono"&gt;main.go&lt;/span&gt;
 &lt;button data-playground="pg-8adfc44969a86fbd6425ddd5b1b6472e"
 class="bg-indigo text-cream text-sm font-bold py-1 px-4 rounded hover:bg-indigo-light transition flex items-center gap-2"&gt;
 &lt;span class="run-icon"&gt;&amp;#9654;&lt;/span&gt;
 &lt;span&gt;تشغيل — Run&lt;/span&gt;
 &lt;/button&gt;
 &lt;/div&gt;
 &lt;textarea id="pg-8adfc44969a86fbd6425ddd5b1b6472e-code" class="code-editor w-full bg-surface-dark-alt text-gray-100 p-4 text-sm leading-relaxed resize-y min-h-[150px] outline-none border-none font-mono" spellcheck="false"&gt;package main

import (
 &amp;#34;fmt&amp;#34;
 &amp;#34;sync&amp;#34;
)

func main() {
 // ❌ بدون حماية — سباق بيانات!
 // Without protection — data race!
 counter := 0
 var wg sync.WaitGroup

 for i := 0; i &amp;lt; 1000; i&amp;#43;&amp;#43; {
 wg.Add(1)
 go func() {
 defer wg.Done()
 counter&amp;#43;&amp;#43; // عدة goroutines تُعدّل نفس المتغير!
 }()
 }

 wg.Wait()
 fmt.Println(&amp;#34;العدّاد (قد يكون خاطئاً):&amp;#34;, counter)
 fmt.Println(&amp;#34;المتوقع: 1000&amp;#34;)
 fmt.Println(&amp;#34;💡 في بيئة حقيقية، استخدم: go run -race main.go&amp;#34;)
}&lt;/textarea&gt;
 &lt;div id="pg-8adfc44969a86fbd6425ddd5b1b6472e-output" class="hidden border-t border-surface-dark-border"&gt;
 &lt;div class="px-4 py-2 bg-surface-dark-alt border-b border-surface-dark-border text-gray-400 text-xs"&gt;Output:&lt;/div&gt;
 &lt;pre class="px-4 py-3 text-sm text-gray-200 bg-[#0d1117] max-h-60 overflow-auto"&gt;&lt;code id="pg-8adfc44969a86fbd6425ddd5b1b6472e-result"&gt;&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;
&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ملاحظة:&lt;/strong&gt; في Go Playground قد تحصل على 1000 أحياناً لأن الجدولة تختلف. لكن على جهازك مع &lt;code&gt;-race&lt;/code&gt; flag ستكتشف المشكلة.&lt;/p&gt;</description></item></channel></rss>