<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anurag Kothare on Medium]]></title>
        <description><![CDATA[Stories by Anurag Kothare on Medium]]></description>
        <link>https://medium.com/@anuragkothare7x?source=rss-5fbdc2b92b7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1nu3s6_YEZO-czXU.</url>
            <title>Stories by Anurag Kothare on Medium</title>
            <link>https://medium.com/@anuragkothare7x?source=rss-5fbdc2b92b7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:47:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anuragkothare7x/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Brewing Concurrency: A Barista’s Guide to Goroutines in Go]]></title>
            <link>https://blog.stackademic.com/go-routines-your-coffee-shop-guide-to-concurrent-programming-73d45e617046?source=rss-5fbdc2b92b7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/73d45e617046</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[concurrency]]></category>
            <dc:creator><![CDATA[Anurag Kothare]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 19:17:10 GMT</pubDate>
            <atom:updated>2024-11-07T01:51:44.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AD94gI8NVN7pe2UinCCEBg.png" /></figure><p><em>Picture yourself in a bustling coffee shop during morning rush hour. Multiple baristas work in parallel, taking orders, grinding beans, and crafting lattes. This is exactly how Go’s concurrency model works with Goroutines. Let’s dive into this perfect blend of simplicity and power.</em></p><p><strong>The Morning Rush: Understanding Concurrency vs. Parallelism</strong></p><p>Before we jump into code, let’s clear up a common confusion. If parallelism is having multiple baristas (CPU cores) working simultaneously, concurrency is about managing multiple tasks efficiently, even with just one barista. Go’s <a href="https://go.dev/tour/concurrency/1">Goroutines</a> excel at both.</p><h3><strong>Your First Goroutine: The Coffee Order</strong></h3><pre>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br><br>type CoffeeOrder struct {<br>    CustomerName string<br>    DrinkType    string<br>}<br><br>func prepareDrink(order CoffeeOrder, done chan bool) {<br>    fmt.Printf(&quot;Starting to prepare %s for %s\n&quot;, order.DrinkType, order.CustomerName)<br>    // Simulate drink preparation time<br>    time.Sleep(2 * time.Second)<br>    fmt.Printf(&quot;Finished %s for %s!\n&quot;, order.DrinkType, order.CustomerName)<br>    done &lt;- true<br>}<br><br>func main() {<br>    orders := []CoffeeOrder{<br>        {&quot;Eren&quot;, &quot;Latte&quot;},<br>        {&quot;Mikasa&quot;, &quot;Espresso&quot;},<br>        {&quot;Levi&quot;, &quot;Cappuccino&quot;},<br>    }<br><br>    // Create a channel to track completion<br>    done := make(chan bool)<br><br>    // Launch a goroutine for each order<br>    for _, order := range orders {<br>        go prepareDrink(order, done)<br>    }<br><br>    // Wait for all orders to complete<br>    for range orders {<br>        &lt;-done<br>    }<br>    <br>    fmt.Println(&quot;All orders completed!&quot;)<br>}</pre><p><strong>Channels: The Coffee Shop’s Communication System</strong></p><p>In our coffee shop, channels are like the order tracking system. They ensure smooth communication between different parts of our operation. Think of them as the numbered buzzers given to customers.</p><p><strong>WaitGroups: The Coffee Shop’s End-of-Shift Checklist System</strong></p><p>Sometimes we need a more structured way to track multiple operations. Enter WaitGroups:</p><pre>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>    &quot;time&quot;<br>)<br><br>func brewCoffee(wg *sync.WaitGroup, name string) {<br>    defer wg.Done()<br>    fmt.Printf(&quot;Starting to brew %s\n&quot;, name)<br>    time.Sleep(1 * time.Second)<br>    fmt.Printf(&quot;Finished brewing %s\n&quot;, name)<br>}<br><br>func main() {<br>    coffeeTypes := []string{&quot;Espresso&quot;, &quot;Pour Over&quot;, &quot;French Press&quot;}<br>    var wg sync.WaitGroup<br><br>    for _, coffee := range coffeeTypes {<br>        wg.Add(1)<br>        go brewCoffee(&amp;wg, coffee)<br>    }<br><br>    wg.Wait()<br>    fmt.Println(&quot;All coffee brewing completed!&quot;)<br>}</pre><p><strong>Managing Concurrent Access: The Shared Coffee Grinder</strong></p><p>When multiple baristas need to use the same resource (like a coffee grinder), we need to manage access. Here’s how mutexes help:</p><pre>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>    &quot;time&quot;<br>)<br><br>type CoffeeGrinder struct {<br>    mu    sync.Mutex<br>    beans int<br>}<br><br>func (g *CoffeeGrinder) Grind(barista string) {<br>    g.mu.Lock()<br>    defer g.mu.Unlock()<br>    <br>    fmt.Printf(&quot;%s is using the grinder\n&quot;, barista)<br>    time.Sleep(500 * time.Millisecond)<br>    g.beans--<br>    fmt.Printf(&quot;%s finished grinding. Beans remaining: %d\n&quot;, barista, g.beans)<br>}<br><br>func main() {<br>    grinder := &amp;CoffeeGrinder{beans: 10}<br>    var wg sync.WaitGroup<br><br>    baristas := []string{&quot;John&quot;, &quot;Maya&quot;, &quot;Jimmy&quot;}<br>    for _, barista := range baristas {<br>        wg.Add(1)<br>        go func(name string) {<br>            defer wg.Done()<br>            grinder.Grind(name)<br>        }(barista)<br>    }<br><br>    wg.Wait()<br>}</pre><h4><strong>Best Practices: The Barista’s Handbook</strong></h4><ul><li><strong>Start Small</strong>: Don’t create Goroutines for tiny tasks. The overhead might not be worth it.</li><li><strong>Clean Up</strong>: Always ensure your Goroutines can finish. Leaked Goroutines are like customers forgotten at their tables.</li><li><strong>Handle Errors</strong>: Use channels or error groups to propagate errors from Goroutines.</li><li><strong>Size Matters</strong>: Consider your system’s resources. Creating thousands of Goroutines is possible but might not be optimal.</li></ul><h3><strong>Conclusion: The Perfect Brew</strong></h3><p>Goroutines are like well-trained baristas — efficient, cooperative, and capable of handling multiple tasks seamlessly. They’re lightweight (using only about 2KB of memory each), can be created by the thousands, and make concurrent programming as smooth as a well-pulled espresso shot.</p><p>Just as a successful coffee shop relies on its team of baristas working in harmony, modern Go applications leverage Goroutines to handle multiple operations efficiently. Whether you are processing orders, brewing coffee, or handling web requests, Goroutines provides the perfect blend of simplicity and power.</p><p>Remember: Just as every great coffee shop has its own rhythm and flow, take time to understand how Goroutines fit into your application’s architecture. Start with simple patterns and gradually work your way up to more complex orchestrations.</p><p>Happy brewing! ☕️</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73d45e617046" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/go-routines-your-coffee-shop-guide-to-concurrent-programming-73d45e617046">Brewing Concurrency: A Barista’s Guide to Goroutines in Go</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Go’s Context Package: From Basics to Advanced Patterns]]></title>
            <link>https://blog.stackademic.com/mastering-gos-context-package-from-basics-to-advanced-patterns-e9286ff3d4f5?source=rss-5fbdc2b92b7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9286ff3d4f5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[context]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Anurag Kothare]]></dc:creator>
            <pubDate>Sun, 27 Oct 2024 19:14:33 GMT</pubDate>
            <atom:updated>2024-11-07T01:51:49.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qzykRrbnS0ag5JhgiDpGw.jpeg" /></figure><p>Imagine you’re building a web service that needs to handle thousands of concurrent requests. Each request triggers multiple database queries, cache lookups, and API calls. Now, what happens when a user cancels their request mid-way? How do you ensure all those background operations stop immediately? How do you prevent resource leaks? How do you maintain request-specific data across your entire call stack?</p><p>This is where Go’s Context package shines.</p><h3>What is Context in Go?</h3><p>At its core, Context is Go’s solution for managing and propagating request-scoped data, deadlines, and cancellation signals across API boundaries. Think of it as a messenger that carries three types of information:</p><ul><li>“When should I stop?” (Cancellation signals)</li><li>“How long do I have?” (Deadlines and timeouts)</li><li>“What’s my request context?” (Request-scoped values)</li></ul><p>Let’s break this down with a real-world analogy:</p><p>Imagine you’re a manager (parent goroutine) assigning tasks to your team members (child goroutines). With Context:</p><ul><li>You can tell all team members to stop working when a project is canceled (cancellation)</li><li>You can set deadlines for task completion (timeouts)</li><li>You can pass along project-specific information that everyone needs (values)</li></ul><h3><strong>Why Context Matters: A Practical Example</strong></h3><p>Here’s a common scenario without Context:</p><pre>func handleRequest(w http.ResponseWriter, r *http.Request) {<br>    // Start a database query<br>    go queryDatabase()<br>    // Make an API call<br>    go callExternalAPI()<br>    // Cache some results<br>    go updateCache()<br>    <br>    // What if the user cancels the request here?<br>    // How do we stop all those goroutines?<br>    // How do we prevent resource leaks?<br>}</pre><p>And here’s the same scenario with Context:</p><pre>func handleRequest(w http.ResponseWriter, r *http.Request) {<br>    ctx := r.Context()<br>    <br>    // If the user cancels their request, ctx.Done() will be closed<br>    go func() {<br>        select {<br>        case &lt;-ctx.Done():<br>            // Clean up resources, stop operations<br>            return<br>        case result := &lt;-queryDatabase(ctx):<br>            // Process result<br>        }<br>    }()<br>    <br>    // All other operations can check ctx.Done()<br>    go callExternalAPI(ctx)<br>    go updateCache(ctx)<br>}</pre><h3><strong>When Should You Use Context?</strong></h3><p>Use Context when you need to:</p><ol><li><strong>Handle Cancellation</strong>:</li></ol><ul><li>Web requests that clients might cancel</li><li>Long-running operations that need timeout capabilities</li><li>Operations that spawn multiple goroutines</li></ul><p>2. <strong>Manage Deadlines</strong>:</p><ul><li>API calls that shouldn’t take longer than X seconds</li><li>Database queries that need timeout controls</li><li>Any operation that shouldn’t run indefinitely</li></ul><p>3. <strong>Pass Request-Scoped Values</strong>:</p><ul><li>Request IDs for tracing</li><li>Authentication tokens</li></ul><p><strong>4. Control Resource Usage</strong>:</p><ul><li>Prevent goroutine leaks</li><li>Clean up resources when operations are cancelled</li><li>Implement timeouts to prevent infinite operations</li></ul><p><strong>The Context Interface</strong></p><p>Let’s look at what makes Context tick:</p><pre>type Context interface {<br>    Deadline() (deadline time.Time, ok bool)<br>    Done() &lt;-chan struct{}<br>    Err() error<br>    Value(key interface{}) interface{}<br>}</pre><ul><li>Deadline(): Tells you when to give up</li><li>Done(): Tells you when to stop</li><li>Err(): Tells you why it stopped</li><li>Value(): Gives you access to request-scoped data</li></ul><h3><strong>Advanced Context Patterns and Real-World Examples</strong></h3><ol><li><strong>Context Chain Pattern</strong></li></ol><p>When building complex applications, you often need to chain multiple operations together. Here’s how to do it effectively:</p><pre>func complexWorkflow(baseCtx context.Context) error {<br>    // Step 1: Add timeout for the entire workflow<br>    workflowCtx, cancel := context.WithTimeout(baseCtx, 30*time.Second)<br>    defer cancel()<br><br>    // Step 2: Add trace ID<br>    tracedCtx := context.WithValue(workflowCtx, &quot;traceID&quot;, generateTraceID())<br><br>    // Step 3: Execute multiple operations with different timeouts<br>    if err := executeStepOne(tracedCtx); err != nil {<br>        return fmt.Errorf(&quot;step one failed: %w&quot;, err)<br>    }<br><br>    if err := executeStepTwo(tracedCtx); err != nil {<br>        return fmt.Errorf(&quot;step two failed: %w&quot;, err)<br>    }<br><br>    return nil<br>}<br><br>func executeStepOne(ctx context.Context) error {<br>    // Create a shorter timeout for this specific step<br>    stepCtx, cancel := context.WithTimeout(ctx, 10*time.Second)<br>    defer cancel()<br><br>    // Get the trace ID from context<br>    traceID := ctx.Value(&quot;traceID&quot;).(string)<br>    log.Printf(&quot;[Trace: %s] Executing step one&quot;, traceID)<br><br>    select {<br>    case &lt;-stepCtx.Done():<br>        return fmt.Errorf(&quot;step one timed out: %v&quot;, stepCtx.Err())<br>    case result := &lt;-doStepOne(stepCtx):<br>        return result<br>    }<br>}</pre><p><strong>2. Context-Aware Resource Pool</strong></p><p>Here’s a pattern for managing a pool of resources with context awareness:</p><pre>type ResourcePool struct {<br>    resources chan *Resource<br>}<br><br>func NewResourcePool(size int) *ResourcePool {<br>    return &amp;ResourcePool{<br>        resources: make(chan *Resource, size),<br>    }<br>}<br><br>func (p *ResourcePool) Acquire(ctx context.Context) (*Resource, error) {<br>    select {<br>    case &lt;-ctx.Done():<br>        return nil, ctx.Err()<br>    case r := &lt;-p.resources:<br>        return r, nil<br>    }<br>}<br><br>func (p *ResourcePool) Release(r *Resource) {<br>    select {<br>    case p.resources &lt;- r:<br>        // Resource returned to pool<br>    default:<br>        // Pool is full, close the resource<br>        r.Close()<br>    }<br>}<br><br>// Usage example<br>func useResource(ctx context.Context, pool *ResourcePool) error {<br>    // Try to acquire resource with timeout<br>    timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)<br>    defer cancel()<br><br>    resource, err := pool.Acquire(timeoutCtx)<br>    if err != nil {<br>        return fmt.Errorf(&quot;failed to acquire resource: %w&quot;, err)<br>    }<br>    defer pool.Release(resource)<br><br>    // Use the resource...<br>    return nil<br>}</pre><p><strong>3. Graceful Shutdown Pattern with Multiple Services</strong></p><pre>type Server struct {<br>    httpServer *http.Server<br>    grpcServer *grpc.Server<br>    db        *sql.DB<br>    cache     *redis.Client<br>}<br><br>func (s *Server) Shutdown(ctx context.Context) error {<br>    // Create error channel to collect shutdown errors<br>    errChan := make(chan error, 4)<br><br>    // Shutdown HTTP server<br>    go func() {<br>        errChan &lt;- s.httpServer.Shutdown(ctx)<br>    }()<br><br>    // Shutdown gRPC server<br>    go func() {<br>        stopped := make(chan struct{})<br>        go func() {<br>            s.grpcServer.GracefulStop()<br>            close(stopped)<br>        }()<br><br>        select {<br>        case &lt;-ctx.Done():<br>            s.grpcServer.Stop()<br>            errChan &lt;- ctx.Err()<br>        case &lt;-stopped:<br>            errChan &lt;- nil<br>        }<br>    }()<br><br>    // Close database connections<br>    go func() {<br>        errChan &lt;- s.db.Close()<br>    }()<br><br>    // Close cache connections<br>    go func() {<br>        errChan &lt;- s.cache.Close()<br>    }()<br><br>    // Collect errors<br>    var errs []error<br>    for i := 0; i &lt; 4; i++ {<br>        if err := &lt;-errChan; err != nil {<br>            errs = append(errs, err)<br>        }<br>    }<br><br>    if len(errs) &gt; 0 {<br>        return fmt.Errorf(&quot;shutdown errors: %v&quot;, errs)<br>    }<br>    return nil<br>}</pre><p><strong>4. Context-Aware Rate Limiter</strong></p><pre>type RateLimiter struct {<br>    tokens  chan struct{}<br>    timeout time.Duration<br>}<br><br>func NewRateLimiter(rate int, timeout time.Duration) *RateLimiter {<br>    rl := &amp;RateLimiter{<br>        tokens:  make(chan struct{}, rate),<br>        timeout: timeout,<br>    }<br><br>    // Fill token bucket<br>    for i := 0; i &lt; rate; i++ {<br>        rl.tokens &lt;- struct{}{}<br>    }<br><br>    return rl<br>}<br><br>func (rl *RateLimiter) Wait(ctx context.Context) error {<br>    select {<br>    case &lt;-ctx.Done():<br>        return ctx.Err()<br>    case &lt;-rl.tokens:<br>        // Got permission to proceed<br>        go func() {<br>            time.Sleep(rl.timeout)<br>            rl.tokens &lt;- struct{}{} // Return token to bucket<br>        }()<br>        return nil<br>    }<br>}<br><br>// Usage example<br>func handleRequests(ctx context.Context) {<br>    limiter := NewRateLimiter(10, time.Second) // 10 requests per second<br><br>    for {<br>        select {<br>        case &lt;-ctx.Done():<br>            return<br>        case req := &lt;-incomingRequests:<br>            if err := limiter.Wait(ctx); err != nil {<br>                handleError(err)<br>                continue<br>            }<br>            go processRequest(req)<br>        }<br>    }<br>}</pre><p><strong>5. Context-Aware Circuit Breaker</strong></p><pre>type CircuitBreaker struct {<br>    failures int64<br>    threshold int64<br>    status int32 // 0: closed, 1: open<br>    timeout time.Duration<br>}<br><br>func (cb *CircuitBreaker) Execute(ctx context.Context, fn func(context.Context) error) error {<br>    if atomic.LoadInt32(&amp;cb.status) == 1 {<br>        return ErrCircuitOpen<br>    }<br><br>    err := fn(ctx)<br>    if err != nil {<br>        if atomic.AddInt64(&amp;cb.failures, 1) &gt;= cb.threshold {<br>            atomic.StoreInt32(&amp;cb.status, 1)<br>            go cb.resetAfterTimeout()<br>        }<br>        return err<br>    }<br><br>    atomic.StoreInt64(&amp;cb.failures, 0)<br>    return nil<br>}<br><br>func (cb *CircuitBreaker) resetAfterTimeout() {<br>    time.Sleep(cb.timeout)<br>    atomic.StoreInt32(&amp;cb.status, 0)<br>    atomic.StoreInt64(&amp;cb.failures, 0)<br>}</pre><p><strong>6. Context-Aware Worker Pool</strong></p><pre>type WorkerPool struct {<br>    workerCount int<br>    tasks       chan Task<br>    results     chan Result<br>}<br><br>func NewWorkerPool(ctx context.Context, workerCount int) *WorkerPool {<br>    pool := &amp;WorkerPool{<br>        workerCount: workerCount,<br>        tasks:      make(chan Task),<br>        results:    make(chan Result),<br>    }<br><br>    for i := 0; i &lt; workerCount; i++ {<br>        go pool.worker(ctx)<br>    }<br><br>    return pool<br>}<br><br>func (p *WorkerPool) worker(ctx context.Context) {<br>    for {<br>        select {<br>        case &lt;-ctx.Done():<br>            return<br>        case task := &lt;-p.tasks:<br>            result := task.Execute(ctx)<br>            select {<br>            case &lt;-ctx.Done():<br>                return<br>            case p.results &lt;- result:<br>            }<br>        }<br>    }<br>}<br><br>func (p *WorkerPool) Submit(ctx context.Context, task Task) (Result, error) {<br>    select {<br>    case &lt;-ctx.Done():<br>        return Result{}, ctx.Err()<br>    case p.tasks &lt;- task:<br>        select {<br>        case &lt;-ctx.Done():<br>            return Result{}, ctx.Err()<br>        case result := &lt;-p.results:<br>            return result, nil<br>        }<br>    }<br>}</pre><p>These patterns demonstrate using Context effectively in real-world scenarios, combining it with other Go concurrency primitives and patterns to build robust, cancellable, deadline-aware systems.</p><h3>Conclusion: Mastering Context for Better Go Applications</h3><p>The Context package is more than just a tool for cancellation or passing values — it’s a fundamental building block for writing robust, maintainable, and scalable Go applications. Through this article, we’ve explored everything from basic usage to advanced patterns, demonstrating how Context helps solve real-world challenges in concurrent programming.</p><h3>Key Takeaways:</h3><ol><li><strong>Use Context Appropriately</strong></li></ol><ul><li>For cancellation signals</li><li>For request-scoped values</li><li>For deadline management</li><li>Not for optional parameters or configuration</li></ul><p><strong>2. Follow Best Practices</strong></p><ul><li>Always pass Context as the first parameter</li><li>Cancel contexts when they’re no longer needed</li><li>Don’t store Contexts in structs</li><li>Keep Context chains shallow and logical</li></ul><p><strong>3. Remember the Power and Responsibility</strong></p><ul><li>Context provides powerful controls for concurrent operations</li><li>With this power comes the responsibility to use it judiciously</li><li>Overuse can lead to complex, hard-to-maintain code</li><li>Choose the simplest solution that meets your needs</li></ul><p>As you build your Go applications, think of Context as your conductor’s baton — it helps orchestrate complex operations, maintain timing, and keep all parts of your program working in harmony. Master it, and you’ll have the tools to build Go applications that are not just functional, but elegant and reliable.</p><p>Happy coding, and may your contexts always be clear! 🚀</p><p><em>Remember: The best code is not just the code that works, but the code that’s clear, maintainable, and respectful of resources. Context helps us achieve all three.</em></p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9286ff3d4f5" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/mastering-gos-context-package-from-basics-to-advanced-patterns-e9286ff3d4f5">Mastering Go’s Context Package: From Basics to Advanced Patterns</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>