<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Learning Resources on Golang4U</title><link>https://golang4u.com/learn/</link><description>Recent content in Learning Resources on Golang4U</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 15 Oct 2026 09:00:00 +0000</lastBuildDate><atom:link href="https://golang4u.com/learn/index.xml" rel="self" type="application/rss+xml"/><item><title>Design Patterns in Go: The Once-per-Lifetime Patterns That Actually Pay Off</title><link>https://golang4u.com/learn/design-patterns-in-go-the-once-per-lifetime-patterns-that-actually-pay-off/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/design-patterns-in-go-the-once-per-lifetime-patterns-that-actually-pay-off/</guid><description>&lt;p&gt;Every Go developer has read &lt;em&gt;Design Patterns&lt;/em&gt; (Gang of Four, 1994) and thought
&amp;ldquo;this is C++-ism&amp;rdquo;. The refactoring.guru catalogue is the friendlier
reference, but most of it is &lt;em&gt;inheritance-based&lt;/em&gt;, and Go has no inheritance.
So what is left? The answer is smaller than you expect, and that is the point.&lt;/p&gt;
&lt;p&gt;This post walks the whole 23-pattern catalogue and marks &lt;strong&gt;which patterns Go
handles natively&lt;/strong&gt; (with the exact idiom) and &lt;strong&gt;which are better left to a
library&lt;/strong&gt;. The organizing rule is the thesis of the post:&lt;/p&gt;</description></item><item><title>gRPC in Go: The Service That Doesn't Need a Microservice Framework</title><link>https://golang4u.com/learn/grpc-in-go-the-service-that-doesnt-need-a-microservice-framework/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/grpc-in-go-the-service-that-doesnt-need-a-microservice-framework/</guid><description>&lt;p&gt;The Java gRPC story is a framework: an &lt;code&gt;@Grpc&lt;/code&gt; annotation, a &lt;code&gt;Service&lt;/code&gt; base class, a &lt;code&gt;Client&lt;/code&gt; interface, a config file. The Go story is the opposite, and it is the reason gRPC in Go feels like using stdlib: &lt;strong&gt;gRPC is a &lt;code&gt;conn&lt;/code&gt; + a generated stub&lt;/strong&gt;. There is no &lt;code&gt;GrpcClient&lt;/code&gt; base class to configure, no service registry to wire. The service is a struct that implements a generated interface; the client is two lines.&lt;/p&gt;</description></item><item><title>Kafka in Go: The Consumer Group That Actually Works</title><link>https://golang4u.com/learn/kafka-in-go-the-consumer-group-that-actually-works/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/kafka-in-go-the-consumer-group-that-actually-works/</guid><description>&lt;p&gt;Every Go service that &amp;ldquo;integrates with Kafka&amp;rdquo; starts the same way and ends the same way: a &lt;code&gt;NewConsumerGroup&lt;/code&gt;, a fetch loop, and a 3am page — the consumer died, the group rebalanced, the committed offset was for the previous batch, and the next batch got delivered twice. The failure is never in the broker. It is in three decisions your service makes: &lt;strong&gt;how it joins the group, when it commits, and what it does on a rebalance.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>PASETO: The Token Format You Didn't Know You Needed</title><link>https://golang4u.com/learn/paseto-the-token-format-you-didnt-know-you-needed/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/paseto-the-token-format-you-didnt-know-you-needed/</guid><description>&lt;p&gt;JWT has been the default for a decade, and the default is the problem. Every
JWT deployment is &lt;em&gt;its own&lt;/em&gt; crypto stack: pick an &lt;code&gt;alg&lt;/code&gt;, pick a &lt;code&gt;kid&lt;/code&gt;, stand up
a JWKS endpoint, wire up an &lt;code&gt;aud&lt;/code&gt; check, and get any of the four wrong and you
have the &lt;strong&gt;&lt;code&gt;alg: &amp;quot;none&amp;quot;&lt;/code&gt;&lt;/strong&gt; bug, the &lt;strong&gt;&lt;code&gt;kid&lt;/code&gt; confusion&lt;/strong&gt; bug, or the
&lt;strong&gt;&amp;ldquo;token signed for service A used against service B&amp;rdquo;&lt;/strong&gt; bug. Paragonie&amp;rsquo;s &amp;ldquo;JWT
is a Bad Standard&amp;rdquo; is the canonical indictment, and PASETO (Platform-Agnostic
SEcurity TOkens) is the fix that ships. The whole idea is to &lt;em&gt;remove the
rope&lt;/em&gt;: one token format, no &lt;code&gt;alg&lt;/code&gt; field, no &lt;code&gt;kid&lt;/code&gt;, no header/body ambiguity —
the version &lt;strong&gt;is&lt;/strong&gt; the algorithm, and the library decides the rest.&lt;/p&gt;</description></item><item><title>The Go Goroutine Pool Pattern That Always Works</title><link>https://golang4u.com/learn/the-go-goroutine-pool-pattern-that-always-works/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/the-go-goroutine-pool-pattern-that-always-works/</guid><description>&lt;p&gt;The goroutine pool is the most over-engineered pattern in the Go ecosystem and the most under-engineered one in production. The standard library gives you &lt;code&gt;sync.WaitGroup&lt;/code&gt; (a barrier, not a pool) and &lt;code&gt;errgroup&lt;/code&gt; (a fan-out, not a pool); everything else — the 40-line &lt;code&gt;WorkerPool&lt;/code&gt; on StackOverflow, the channel-based &amp;ldquo;pool&amp;rdquo; in every blog post — is a re-implementation of the same 50-line pattern, each with a slightly different name for the &lt;em&gt;slot&lt;/em&gt; and a slightly different condition for &lt;em&gt;slot free&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>The Jailer in My Codebase: In-Memory Jail and Why It Became a Library</title><link>https://golang4u.com/learn/the-jailer-in-my-codebase-in-memory-jail-and-why-it-became-a-library/</link><pubDate>Thu, 15 Oct 2026 09:00:00 +0000</pubDate><guid>https://golang4u.com/learn/the-jailer-in-my-codebase-in-memory-jail-and-why-it-became-a-library/</guid><description>&lt;p&gt;Every login system grows a jail. Mine started as a &lt;code&gt;map[string]int&lt;/code&gt; of failed logins and a comment saying &amp;ldquo;5 and they&amp;rsquo;re out&amp;rdquo;. Six sprints later it was a 300-line blob with three kinds of counters, two kinds of windows, and a backoff that someone hand-tuned in production at 3am. The &lt;em&gt;data&lt;/em&gt; never changed; the &lt;strong&gt;rules&lt;/strong&gt; did — what counts as a try, what &amp;ldquo;exceeding&amp;rdquo; a budget means, who gets jailed and for how long.&lt;/p&gt;</description></item><item><title>The Golang4U LLM Bible: Internals of the Intelligent Llama Manager</title><link>https://golang4u.com/learn/llama_manager_blog/</link><pubDate>Tue, 10 Mar 2026 00:00:00 +0800</pubDate><guid>https://golang4u.com/learn/llama_manager_blog/</guid><description>&lt;h1 id="preface-why-native-llamacpp-is-painful" class="headerLink"&gt;
 &lt;a href="#preface-why-native-llamacpp-is-painful" class="header-mark"&gt;&lt;/a&gt;Preface: Why Native llama.cpp is Painful&lt;/h1&gt;&lt;p&gt;Running Large Language Models (LLMs) locally using &lt;code&gt;llama.cpp&lt;/code&gt; offers incredible privacy and performance. However, deploying it effectively is notoriously difficult. The native experience is raw: compiling binaries manually, dealing with unoptimized package manager downloads, juggling 50GB file transfers, calculating mental VRAM boundaries, and memorizing arcane CLI flags. Get a single context metric wrong, and your GPU violently crashes with an Out-Of-Memory (OOM) panic.&lt;/p&gt;
&lt;p&gt;We built an all-in-one Go application—&lt;code&gt;llama_manager.go&lt;/code&gt;—to solve this entirely. It is a highly fault-tolerant daemon that dynamically profiles physical hardware, reverse-engineers a model&amp;rsquo;s memory footprint on the fly, and calculates the exact parameters needed to run engines at absolute peak efficiency.&lt;/p&gt;</description></item><item><title>The Golang4U Cryptography Bible: E2EE, ECIES &amp; Blind Indexing</title><link>https://golang4u.com/learn/cryptography-in-depth/</link><pubDate>Tue, 10 Feb 2026 16:00:00 +0800</pubDate><guid>https://golang4u.com/learn/cryptography-in-depth/</guid><description>&lt;h1 id="preface-why-tls-is-not-enough" class="headerLink"&gt;
 &lt;a href="#preface-why-tls-is-not-enough" class="header-mark"&gt;&lt;/a&gt;Preface: Why TLS is Not Enough&lt;/h1&gt;&lt;p&gt;HTTPS (TLS 1.3) protects data &amp;ldquo;In Transit.&amp;rdquo;
It prevents the Hacker in the Coffee Shop from reading your password.
But it does &lt;strong&gt;not&lt;/strong&gt; protect against:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Malicious Proxies&lt;/strong&gt;: A corporate proxy (MITM) that terminates TLS.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Server Itself&lt;/strong&gt;: If our logs accidentally print &lt;code&gt;req.Body&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory Dumps&lt;/strong&gt;: If the server crashes and dumps RAM.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To fix this, we implement &lt;strong&gt;End-to-End Encryption (E2EE)&lt;/strong&gt; at the Application Layer.
The password is encrypted &lt;em&gt;in the browser&lt;/em&gt; and only decrypted &lt;em&gt;inside the Service function&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>The Golang4U Authentication Bible: PASETO, Usage &amp; Design</title><link>https://golang4u.com/learn/modern-authentication/</link><pubDate>Tue, 10 Feb 2026 14:00:00 +0800</pubDate><guid>https://golang4u.com/learn/modern-authentication/</guid><description>&lt;h1 id="preface-authentication-vs-authorization" class="headerLink"&gt;
 &lt;a href="#preface-authentication-vs-authorization" class="header-mark"&gt;&lt;/a&gt;Preface: Authentication vs Authorization&lt;/h1&gt;&lt;p&gt;First, a distinction.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Authentication (AuthN)&lt;/strong&gt;: &amp;ldquo;Who are you?&amp;rdquo; (I am User 123).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Authorization (AuthZ)&lt;/strong&gt;: &amp;ldquo;What can you do?&amp;rdquo; (I can delete posts).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This, guide focuses on &lt;strong&gt;AuthN&lt;/strong&gt;. specifically, how we securely identify a user across stateless HTTP requests.&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id="chapter-1-the-fall-of-jwt-json-web-tokens" class="headerLink"&gt;
 &lt;a href="#chapter-1-the-fall-of-jwt-json-web-tokens" class="header-mark"&gt;&lt;/a&gt;Chapter 1: The Fall of JWT (JSON Web Tokens)&lt;/h1&gt;&lt;p&gt;For a decade, JWT (RFC 7519) was the king. But heavy lies the crown.
A JWT is a string: &lt;code&gt;header.payload.signature&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="the-design-flaw-cipher-agility" class="headerLink"&gt;
 &lt;a href="#the-design-flaw-cipher-agility" class="header-mark"&gt;&lt;/a&gt;The Design Flaw: Cipher Agility&lt;/h3&gt;&lt;p&gt;The header tells the server how to verify the token.&lt;/p&gt;</description></item><item><title>The Golang4U Security Bible: A Defense-in-Depth Masterclass</title><link>https://golang4u.com/learn/advanced-security/</link><pubDate>Tue, 10 Feb 2026 12:00:00 +0800</pubDate><guid>https://golang4u.com/learn/advanced-security/</guid><description>&lt;h1 id="preface-the-zero-trust-mindset" class="headerLink"&gt;
 &lt;a href="#preface-the-zero-trust-mindset" class="header-mark"&gt;&lt;/a&gt;Preface: The Zero Trust Mindset&lt;/h1&gt;&lt;p&gt;Security is often treated as a feature. &amp;ldquo;Add a login page, and we&amp;rsquo;re secure.&amp;rdquo;
This is false.
Security is a &lt;strong&gt;Process&lt;/strong&gt;. It is the sum of every line of code that handles input.&lt;/p&gt;
&lt;p&gt;In &lt;strong&gt;Golang4U&lt;/strong&gt;, we adopt a &lt;strong&gt;Zero Trust&lt;/strong&gt; mindset.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Trust No IP&lt;/strong&gt;: Even if it didn&amp;rsquo;t attack us yesterday, it might attack us today.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trust No User&lt;/strong&gt;: Even if they have a valid token, they might be spamming.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trust No Browser&lt;/strong&gt;: Even if Chrome says it&amp;rsquo;s secure, we enforce it with headers.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This guide will walk you through the three rings of defense: &lt;strong&gt;Network&lt;/strong&gt;, &lt;strong&gt;Application&lt;/strong&gt;, and &lt;strong&gt;Presentation&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>The Golang4U Architecture: A Service-Oriented Masterclass</title><link>https://golang4u.com/learn/architecture-deep-dive/</link><pubDate>Tue, 10 Feb 2026 10:00:00 +0800</pubDate><guid>https://golang4u.com/learn/architecture-deep-dive/</guid><description>&lt;h1 id="preface-why-read-this" class="headerLink"&gt;
 &lt;a href="#preface-why-read-this" class="header-mark"&gt;&lt;/a&gt;Preface: Why Read This?&lt;/h1&gt;&lt;p&gt;If you are just starting with Go, you might write everything in &lt;code&gt;main.go&lt;/code&gt;. It works for a &amp;ldquo;Hello World,&amp;rdquo; but it fails for a production system.
If you are an expert, you might argue about &amp;ldquo;Clean Architecture&amp;rdquo; vs &amp;ldquo;Hexagonal&amp;rdquo; vs &amp;ldquo;Onion.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Golang4U&lt;/strong&gt; adopts a pragmatic, production-ready &lt;strong&gt;Service-Oriented Architecture (SOA)&lt;/strong&gt; structure. It is designed to be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Testable&lt;/strong&gt;: Every layer can be mocked.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalable&lt;/strong&gt;: New features (like a &amp;ldquo;Video&amp;rdquo; post type) don&amp;rsquo;t break old ones.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Readable&lt;/strong&gt;: A new developer knows exactly where to put code.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This guide is not a summary. It is a &lt;strong&gt;Masterclass&lt;/strong&gt;. We will read the code together, line by line, layer by layer. By the end, you will understand not just &lt;em&gt;how&lt;/em&gt; it works, but &lt;em&gt;why&lt;/em&gt; it was built this way.&lt;/p&gt;</description></item><item><title/><link>https://golang4u.com/learn/domain-driven-design/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang4u.com/learn/domain-driven-design/</guid><description>&lt;h2 id="draft-false" class="headerLink"&gt;
 &lt;a href="#draft-false" class="header-mark"&gt;&lt;/a&gt;title: &amp;ldquo;Domain-Driven Design in Go: the Rich Model, the User/Store split, and the referral-code algorithm&amp;rdquo;
image: /images/covers/domain-driven-design.svg
date: 2026-10-17T09:00:00+00:00
author: &amp;ldquo;Punit Naran&amp;rdquo;
description: &amp;ldquo;Anemic Domain Models are data bags with all the logic in Services. The Rich Model puts behavior on the struct. This post is the Golang4U domain layer: the User business entity (constructor-validated, never nil-shaped), the Store persistence record (system metadata the API must never leak), and the collision-free referral-code minting algorithm that lives on the record, not the service. Every code block here compiles with the stdlib alone.&amp;rdquo;
tags: [&amp;ldquo;Go&amp;rdquo;, &amp;ldquo;DDD&amp;rdquo;, &amp;ldquo;Rich Model&amp;rdquo;, &amp;ldquo;Domain-Driven-Design&amp;rdquo;, &amp;ldquo;Validation&amp;rdquo;]
draft: false&lt;/h2&gt;&lt;h1 id="domain-driven-design-in-go-the-rich-model-the-userstore-split-and-the-referral-code-algorithm" class="headerLink"&gt;
 &lt;a href="#domain-driven-design-in-go-the-rich-model-the-userstore-split-and-the-referral-code-algorithm" class="header-mark"&gt;&lt;/a&gt;Domain-Driven Design in Go: the Rich Model, the User/Store split, and the referral-code algorithm&lt;/h1&gt;&lt;p&gt;The classic Go &amp;ldquo;gotcha&amp;rdquo; is not a concurrency bug — it is the &lt;strong&gt;anemic domain model&lt;/strong&gt;: your structs are data bags (&lt;code&gt;type User struct { Name string }&lt;/code&gt;) and &lt;em&gt;all&lt;/em&gt; the behavior lives in a &lt;code&gt;Service&lt;/code&gt; (&lt;code&gt;func (s *Service) IsAdult(u *User) bool { return u.Age &amp;gt;= 18 }&lt;/code&gt;). The result is a codebase where the &lt;em&gt;data&lt;/em&gt; has no &lt;em&gt;semantics&lt;/em&gt;, and the &lt;em&gt;semantics&lt;/em&gt; have no &lt;em&gt;home&lt;/em&gt; — every rule is a function that takes a data bag and a flag, and the &lt;em&gt;type system&lt;/em&gt; is telling you &lt;em&gt;nothing&lt;/em&gt; about what a valid &lt;code&gt;User&lt;/code&gt; is. This post is the &lt;strong&gt;Rich Model&lt;/strong&gt; in Go, from the Golang4U domain layer: a &lt;code&gt;User&lt;/code&gt; that &lt;em&gt;is&lt;/em&gt; structurally valid (every constructor validates it once, at the boundary), a &lt;code&gt;Store&lt;/code&gt; record that &lt;em&gt;wraps&lt;/em&gt; the &lt;code&gt;User&lt;/code&gt; with system metadata the API must &lt;em&gt;never&lt;/em&gt; leak, and a &lt;strong&gt;referral-code minting algorithm&lt;/strong&gt; that lives on the &lt;em&gt;record&lt;/em&gt; (because it mutates the record&amp;rsquo;s referral list) — not in the service, not in a helper, &lt;em&gt;right where the data lives.&lt;/em&gt;&lt;/p&gt;</description></item><item><title/><link>https://golang4u.com/learn/implementing-2fa/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang4u.com/learn/implementing-2fa/</guid><description>&lt;h2 id="draft-false" class="headerLink"&gt;
 &lt;a href="#draft-false" class="header-mark"&gt;&lt;/a&gt;title: &amp;ldquo;Implementing 2FA in Go: TOTP from RFC 6238, the 3-phase enrollment state machine, and recovery codes — stdlib only&amp;rdquo;
image: /images/covers/implementing-2fa.svg
date: 2026-10-17T09:00:00+00:00
author: &amp;ldquo;Punit Naran&amp;rdquo;
description: &amp;ldquo;Two-factor authentication is a function of time and a shared secret, and the whole standard (RFC 6238) fits in ~80 lines of Go stdlib: crypto/hmac, crypto/rand, encoding/base32. This post implements TOTP from the RFC, the 3-phase setup/activate/commit state machine that prevents the classic &amp;lsquo;I scanned the QR but my phone broke&amp;rsquo; lockout, a ±1 clock-drift window, and one-shot recovery codes stored as hashes — all with no third-party TOTP SDK.&amp;rdquo;
tags: [&amp;ldquo;Go&amp;rdquo;, &amp;ldquo;Authentication&amp;rdquo;, &amp;ldquo;2FA&amp;rdquo;, &amp;ldquo;TOTP&amp;rdquo;, &amp;ldquo;RFC 6238&amp;rdquo;, &amp;ldquo;Recovery Codes&amp;rdquo;, &amp;ldquo;State Machine&amp;rdquo;]
draft: false&lt;/h2&gt;&lt;h1 id="implementing-2fa-in-go-totp-from-rfc-6238-the-3-phase-enrollment-state-machine-and-recovery-codes" class="headerLink"&gt;
 &lt;a href="#implementing-2fa-in-go-totp-from-rfc-6238-the-3-phase-enrollment-state-machine-and-recovery-codes" class="header-mark"&gt;&lt;/a&gt;Implementing 2FA in Go: TOTP from RFC 6238, the 3-phase enrollment state machine, and recovery codes&lt;/h1&gt;&lt;p&gt;The standard &amp;ldquo;you need a TOTP SDK&amp;rdquo; answer is &lt;em&gt;wrong for Go&lt;/em&gt;: the entire TOTP standard (RFC 6238) is &lt;strong&gt;a function of time and a shared secret, computed with HMAC-SHA1&lt;/strong&gt; — and Go&amp;rsquo;s stdlib already ships &lt;code&gt;crypto/hmac&lt;/code&gt;, &lt;code&gt;crypto/rand&lt;/code&gt;, and &lt;code&gt;encoding/base32&lt;/code&gt;. &lt;em&gt;A&lt;/em&gt; &lt;em&gt;complete&lt;/em&gt; &lt;em&gt;2FA&lt;/em&gt; &lt;em&gt;implementation&lt;/em&gt; (secret &lt;em&gt;generation,&lt;/em&gt; &lt;em&gt;code&lt;/em&gt; &lt;em&gt;generation,&lt;/em&gt; &lt;em&gt;validation&lt;/em&gt; &lt;em&gt;with&lt;/em&gt; &lt;em&gt;a&lt;/em&gt; &lt;em&gt;drift&lt;/em&gt; &lt;em&gt;window,&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; *&lt;code&gt;otpauth://&lt;/code&gt; &lt;em&gt;enrollment&lt;/em&gt; &lt;em&gt;URI,&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;3-phase&lt;/em&gt; &lt;em&gt;setup/activate/commit&lt;/em&gt; &lt;em&gt;state&lt;/em&gt; &lt;em&gt;machine,&lt;/em&gt; &lt;em&gt;and&lt;/em&gt; &lt;em&gt;one-shot&lt;/em&gt; &lt;em&gt;recovery&lt;/em&gt; *codes) &lt;em&gt;fits&lt;/em&gt; &lt;em&gt;in&lt;/em&gt; &lt;em&gt;under&lt;/em&gt; &lt;em&gt;200&lt;/em&gt; &lt;em&gt;lines&lt;/em&gt; &lt;em&gt;of&lt;/em&gt; &lt;em&gt;stdlib&lt;/em&gt; &lt;em&gt;Go.&lt;/em&gt; &lt;em&gt;The&lt;/em&gt; &lt;em&gt;thesis&lt;/em&gt; &lt;em&gt;of&lt;/em&gt; &lt;em&gt;this&lt;/em&gt; &lt;em&gt;post&lt;/em&gt; &lt;em&gt;is&lt;/em&gt; &lt;em&gt;that&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;two&lt;/em&gt; &lt;em&gt;hard&lt;/em&gt; &lt;em&gt;parts&lt;/em&gt; &lt;em&gt;of&lt;/em&gt; &lt;em&gt;2FA&lt;/em&gt; &lt;em&gt;are&lt;/em&gt; &lt;em&gt;not&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;crypto&lt;/em&gt; (the &lt;em&gt;crypto&lt;/em&gt; &lt;em&gt;is&lt;/em&gt; &lt;em&gt;one&lt;/em&gt; &lt;em&gt;HMAC&lt;/em&gt; *call) *— &lt;em&gt;they&lt;/em&gt; &lt;em&gt;are&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;state&lt;/em&gt; &lt;em&gt;machine&lt;/em&gt; (a &lt;em&gt;user&lt;/em&gt; &lt;em&gt;who&lt;/em&gt; &lt;em&gt;scans&lt;/em&gt; &lt;em&gt;a&lt;/em&gt; &lt;em&gt;QR&lt;/em&gt; &lt;em&gt;but&lt;/em&gt; &lt;em&gt;never&lt;/em&gt; &lt;em&gt;activates&lt;/em&gt; &lt;em&gt;must&lt;/em&gt; &lt;em&gt;never&lt;/em&gt; &lt;em&gt;be&lt;/em&gt; &lt;em&gt;locked&lt;/em&gt; *out) &lt;em&gt;and&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;recovery&lt;/em&gt; &lt;em&gt;path&lt;/em&gt; (a &lt;em&gt;user&lt;/em&gt; &lt;em&gt;who&lt;/em&gt; &lt;em&gt;loses&lt;/em&gt; &lt;em&gt;their&lt;/em&gt; &lt;em&gt;phone&lt;/em&gt; &lt;em&gt;must&lt;/em&gt; &lt;em&gt;not&lt;/em&gt; &lt;em&gt;be&lt;/em&gt; &lt;em&gt;gone&lt;/em&gt; &lt;em&gt;for&lt;/em&gt; *good). &lt;em&gt;The&lt;/em&gt; &lt;em&gt;state&lt;/em&gt; &lt;em&gt;machine&lt;/em&gt; &lt;em&gt;and&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;recovery&lt;/em&gt; &lt;em&gt;codes&lt;/em&gt; &lt;em&gt;are&lt;/em&gt; &lt;em&gt;where&lt;/em&gt; &lt;em&gt;2FA&lt;/em&gt; &lt;em&gt;systems&lt;/em&gt; &lt;em&gt;actually&lt;/em&gt; &lt;em&gt;fail,&lt;/em&gt; &lt;em&gt;and&lt;/em&gt; &lt;em&gt;they&lt;/em&gt; &lt;em&gt;are&lt;/em&gt; &lt;em&gt;exactly&lt;/em&gt; &lt;em&gt;the&lt;/em&gt; &lt;em&gt;parts&lt;/em&gt; &lt;em&gt;a&lt;/em&gt; &lt;em&gt;SDK&lt;/em&gt; &lt;em&gt;hides&lt;/em&gt; &lt;em&gt;from&lt;/em&gt; &lt;em&gt;you.&lt;/em&gt;&lt;/p&gt;</description></item><item><title/><link>https://golang4u.com/learn/production-hardening/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang4u.com/learn/production-hardening/</guid><description>&lt;p&gt;title: &amp;ldquo;The Golang4U Hardening Bible: DDoS-Proofing &amp;amp; OOM Prevention&amp;rdquo;
image: /images/covers/production-hardening.svg
date: 2026-02-14T15:00:00+08:00
lastmod: 2026-02-14T15:00:00+08:00
author: &amp;ldquo;Punit Naran&amp;rdquo;
authorLink: &amp;quot;&amp;quot;
description: &amp;ldquo;Your code is correct, but your server is vulnerable. The Golang4U hardening playbook: Slowloris timeouts, GOMEMLIMIT OOM prevention, and bounded database pooling - the runtime knobs that stop the 3 a.m. page.&amp;rdquo;
tags: [&amp;ldquo;Go&amp;rdquo;, &amp;ldquo;DevOps&amp;rdquo;, &amp;ldquo;DDoS&amp;rdquo;, &amp;ldquo;OOM&amp;rdquo;, &amp;ldquo;GOMEMLIMIT&amp;rdquo;, &amp;ldquo;Production&amp;rdquo;, &amp;ldquo;Docker&amp;rdquo;, &amp;ldquo;Kubernetes&amp;rdquo;]
categories: [&amp;ldquo;DevOps&amp;rdquo;, &amp;ldquo;Engineering Handbook&amp;rdquo;]
featuredImage: &amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;Your code is correct. It passed every test. Then the 3 a.m. page: OOM kill, a hung pool of connections, a Slowloris-shaped incident. The difference is that &lt;strong&gt;default settings are tuned for a laptop demo, not a production box&lt;/strong&gt;. This post is the Golang4U hardening playbook, told through the runtime&amp;rsquo;s own knobs: &lt;code&gt;GOMEMLIMIT&lt;/code&gt;, the HTTP server timeout ladder, and database pooling.&lt;/p&gt;</description></item><item><title/><link>https://golang4u.com/learn/secure-file-uploads/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang4u.com/learn/secure-file-uploads/</guid><description>&lt;p&gt;title: &amp;ldquo;Secure file uploads in Go: magic-byte sniffing, streaming to ClamAV, and a SANE-style frame client that never touches the disk&amp;rdquo;
image: /images/covers/secure-file-uploads.svg
date: 2026-10-17T09:00:00+00:00
author: &amp;ldquo;Punit Naran&amp;rdquo;
description: &amp;ldquo;A file-upload endpoint is a backdoor: a shell in a .jpg, a virus in a PDF, a 50GB file that fills the disk. This post treats every upload as a potential bomb and defuses it the Go way: http.DetectContentType (magic bytes, not the Content-Type header) for the format check, a ClamAV streaming scan over a TCP pipe so the file is &lt;em&gt;checked before it is stored&lt;/em&gt;, a body-size limit that severs the request before it hits RAM, and an IP ban that turns the endpoint into a honeypot. The streaming frame client (a SANE-style request/response protocol) is the Go idiom for &amp;lsquo;consume a byte stream without buffering the whole thing&amp;rsquo;.&amp;rdquo;
tags: [&amp;ldquo;Go&amp;rdquo;, &amp;ldquo;Security&amp;rdquo;, &amp;ldquo;ClamAV&amp;rdquo;, &amp;ldquo;FileUploads&amp;rdquo;, &amp;ldquo;Streaming&amp;rdquo;, &amp;ldquo;Magic Bytes&amp;rdquo;, &amp;ldquo;DoS&amp;rdquo;]
draft: false&lt;/p&gt;</description></item><item><title/><link>https://golang4u.com/learn/transactional-email/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang4u.com/learn/transactional-email/</guid><description>&lt;p&gt;title: &amp;ldquo;The Golang4U Email Bible: Native SMTP &amp;amp; Transactional Systems&amp;rdquo;
image: /images/covers/transactional-email.svg
date: 2026-02-14T11:00:00+08:00
lastmod: 2026-02-14T11:00:00+08:00
author: &amp;ldquo;Punit Naran&amp;rdquo;
authorLink: &amp;quot;&amp;quot;
description: &amp;ldquo;A reliable transactional mailer on the Go standard library only: the raw SMTP conversation, the net/smtp sender, and a bounded worker-pool queue with a dead letter - no vendor, no SDK.&amp;rdquo;
tags: [&amp;ldquo;Go&amp;rdquo;, &amp;ldquo;Email&amp;rdquo;, &amp;ldquo;SMTP&amp;rdquo;, &amp;ldquo;TransactionEmail&amp;rdquo;, &amp;ldquo;StandardLib&amp;rdquo;, &amp;ldquo;NoDependencies&amp;rdquo;]
categories: [&amp;ldquo;Architecture&amp;rdquo;, &amp;ldquo;Engineering Handbook&amp;rdquo;]
featuredImage: &amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;Every startup guide says: &amp;ldquo;sign up for SendGrid / Mailgun / AWS SES.&amp;rdquo; The cost: API keys to rotate, webhooks to build, SDKs to pin, and lock-in that turns a provider switch into a rewrite. Golang4U&amp;rsquo;s answer is the &lt;strong&gt;standard library&lt;/strong&gt;: &lt;code&gt;net/smtp&lt;/code&gt; is battle-hardened and speaks the raw protocol of the internet. This post is the email system we actually run — a reliable transactional mailer built on &lt;code&gt;net/smtp&lt;/code&gt;, a worker-pool queue, and no vendor.&lt;/p&gt;</description></item></channel></rss>