
  <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
      <title>Duncan Leung</title>
      <link>https://www.duncanleung.com/blog</link>
      <description>📚 Learning, 👨🏻‍💻 Building, 📝 Documenting...</description>
      <language>en-us</language>
      <managingEditor>duncan@leungs.email (Duncan Leung)</managingEditor>
      <webMaster>duncan@leungs.email (Duncan Leung)</webMaster>
      <lastBuildDate>Mon, 03 May 2021 00:00:00 GMT</lastBuildDate>
      <atom:link href="https://www.duncanleung.com/tags/backend/feed.xml" rel="self" type="application/rss+xml"/>
      
  <item>
    <guid>https://www.duncanleung.com/blog/golang-readers-writers</guid>
    <title>The io.Reader and io.Writer Interfaces in Go</title>
    <link>https://www.duncanleung.com/blog/golang-readers-writers</link>
    <description>Understanding the io.Reader and io.Writer interfaces in Go, and how accepting an io.Writer parameter makes your code flexible across files, HTTP responses, stdout, and in-memory buffers.</description>
    <pubDate>Mon, 03 May 2021 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/self-hosting-go-binary-aws-ec2-systemd</guid>
    <title>Self-Hosting a Go Binary on AWS EC2</title>
    <link>https://www.duncanleung.com/blog/self-hosting-go-binary-aws-ec2-systemd</link>
    <description>Deploying a Go service to a single AWS EC2 instance as a hardened systemd service - cross-compiling the binary, copying it across, creating a non-root service user, configuring systemd with the right hardening directives, and handling graceful shutdown.</description>
    <pubDate>Mon, 03 May 2021 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category><category>aws</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/iterating-index-strings-runes-go-golang</guid>
    <title>Indexing Strings and Runes in Go</title>
    <link>https://www.duncanleung.com/blog/iterating-index-strings-runes-go-golang</link>
    <description>Understanding the difference between indexing strings as bytes versus runes in Go, and when to use each approach for proper Unicode handling.</description>
    <pubDate>Wed, 16 Jun 2021 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/go-basic-data-structures-types-pointers-structs-arrays-slices-int-float-string</guid>
    <title>Basic Data Structures in Go</title>
    <link>https://www.duncanleung.com/blog/go-basic-data-structures-types-pointers-structs-arrays-slices-int-float-string</link>
    <description>Understanding Go data structures and their memory layout including integers, floats, arrays, pointers, structs, strings, and slices.</description>
    <pubDate>Fri, 09 Jul 2021 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/understand-go-golang-interfaces</guid>
    <title>Understanding Interfaces in Go</title>
    <link>https://www.duncanleung.com/blog/understand-go-golang-interfaces</link>
    <description>A guide to understand Go interfaces through a power socket and electrical device analogy, covering duck typing and interface implementation.</description>
    <pubDate>Thu, 23 Dec 2021 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/go-function-arguments-passed-by-value</guid>
    <title>Go Function Argument Passing Behavior</title>
    <link>https://www.duncanleung.com/blog/go-function-arguments-passed-by-value</link>
    <description>How Go passes function arguments by value and the implications for different data types: integers, pointers, slices, strings, and structs.</description>
    <pubDate>Thu, 08 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/go-json-encoding-and-decoding</guid>
    <title>JSON Encoding and Decoding in Go</title>
    <link>https://www.duncanleung.com/blog/go-json-encoding-and-decoding</link>
    <description>A guide to JSON serialization and deserialization in Go, covering type mappings, HTTP responses, and practical examples with the net/http package.</description>
    <pubDate>Mon, 19 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/slices-in-go</guid>
    <title>Slices in Go</title>
    <link>https://www.duncanleung.com/blog/slices-in-go</link>
    <description>Understanding Go slices, their underlying array structure, creation and modification mechanics, and the implications when passing slices to functions.</description>
    <pubDate>Mon, 26 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/allocating-memory-go</guid>
    <title>Allocating Memory in Go</title>
    <link>https://www.duncanleung.com/blog/allocating-memory-go</link>
    <description>Understanding memory allocation in Go, including stack vs heap allocation, escape analysis, and how Go handles pointer returns from functions.</description>
    <pubDate>Wed, 28 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/methods-in-go</guid>
    <title>Methods in Go</title>
    <link>https://www.duncanleung.com/blog/methods-in-go</link>
    <description>Understanding Go methods, the difference between value and pointer receivers, embedding for composition, and how interfaces work with methods.</description>
    <pubDate>Wed, 28 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/go-idiom-accept-interfaces-return-types</guid>
    <title>Go Idioms: Accept Interfaces, Return Types</title>
    <link>https://www.duncanleung.com/blog/go-idiom-accept-interfaces-return-types</link>
    <description>Understanding the Go idiom of accepting interfaces and returning concrete types to write flexible, reusable, and maintainable code.</description>
    <pubDate>Fri, 30 Jun 2023 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/go-interface-segregation-shared-singletons</guid>
    <title>Producer, Service, ProducerService: Interface Segregation for Shared Singletons in Go</title>
    <link>https://www.duncanleung.com/blog/go-interface-segregation-shared-singletons</link>
    <description>When one Go struct legitimately serves multiple consumer roles - producer, service, admin - declare three interfaces and let DI cache the singleton at the wide type while each consumer holds only the methods it can call. Same shape as io.ReadWriteCloser in the stdlib.</description>
    <pubDate>Thu, 30 Apr 2026 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/postgres-where-status-idempotent-sqs-worker</guid>
    <title>Idempotent SQS Workers with Postgres UPDATE: The WHERE-Status Pattern</title>
    <link>https://www.duncanleung.com/blog/postgres-where-status-idempotent-sqs-worker</link>
    <description>Most SQS idempotency guides reach for Redis dedupe keys or dedupe tables. If your worker&#39;s job ends in a terminal state-machine transition, the row&#39;s own status column is already the lock - and one UPDATE statement is the entire safety story.</description>
    <pubDate>Thu, 30 Apr 2026 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>backend</category><category>go</category><category>aws</category><category>postgres</category>
  </item>

  <item>
    <guid>https://www.duncanleung.com/blog/nextjs-module-load-env-guards-structural-validation</guid>
    <title>Module-Load Env Guards in Next.js: Why DATABASE_URL Needs Structural Validation</title>
    <link>https://www.duncanleung.com/blog/nextjs-module-load-env-guards-structural-validation</link>
    <description>Most env-var validation checks that values exist. That catches missing config but misses the worse case - a value that is present, valid in shape, and silently wrong. Here is the asymmetric pattern for separating loud failures from silent ones in a Next.js server.</description>
    <pubDate>Tue, 12 May 2026 00:00:00 GMT</pubDate>
    <author>duncan@leungs.email (Duncan Leung)</author>
    <category>nextjs</category><category>typescript</category><category>backend</category><category>security</category>
  </item>

    </channel>
  </rss>
