Below you will find pages that utilize the taxonomy term “Golang”
Building a Tiny HTTP Server from Scratch with net + bufio
Go’s net/http package is fantastic—but sometimes you want to see what’s really happening under the hood.
In this article, we’ll build a tiny HTTP/1.1 server from scratch, using only:
net— for TCP socketsbufio— for buffered I/O
No net/http, no handler interface, no magic.
You’ll learn:
- How HTTP/1.1 requests look on the wire
- How to parse the request line and headers
- How to build a minimal response (status line, headers, body)
- How to handle multiple connections with goroutines
- A tiny router for different paths
This is not production code—it’s a learning tool. But it’s a great way to deeply understand HTTP.
A Deep Dive into Go’s net/http Internals
Go’s net/http package is deceptively simple on the surface—just call http.ListenAndServe() and pass a handler. But beneath its minimal API lies a highly optimized, battle-tested, and beautifully engineered HTTP runtime.
This article explores the internal architecture, concurrency model, lifecycle, request handling flow, connection reuse, transport behaviors, and performance strategies that make net/http one of Go’s most iconic packages.
This is a true deep dive—use it to understand how Go’s HTTP stack really works under the hood.
Designing a High-Performance, Multi-Goroutine Socket Server in Go
High-performance networking is one of Go’s strengths. With lightweight goroutines, a rich net package, and strong concurrency primitives, Go is a great fit for building custom TCP servers, game backends, proxies, and internal protocols.
In this article, we’ll design and implement a high-performance, multi-goroutine socket server in Go, with an architecture you can evolve into a real-world production system.
We’ll cover:
- Architecture and design goals
- A baseline TCP server
- A multi-goroutine concurrency model
- Connection limits and backpressure
- Request handling with worker pools
- Graceful shutdown and observability
1. Goals and Design Principles
We’ll design a server that:
A Deep Dive into Go’s net Package: Networking from First Principles
The net package is the foundation of all network programming in Go.
Everything — from HTTP servers to gRPC, Redis clients, DNS resolvers, and low-level TCP/UDP tools — ultimately relies on Go’s networking stack built around the net package.
This article provides a deep, practical, and complete exploration of net with clear explanations and runnable examples.
1. Why the net Package Matters
Go’s networking model is:
- Simple – Uses familiar Unix-style sockets and file descriptors.
- Cross-platform – Same code works on Linux, macOS, Windows.
- Concurrent by design – Each connection can be handled by a goroutine.
- Powerful – TCP, UDP, Unix domain sockets, DNS, interfaces, IPs, CIDR tools, etc.
Higher-level packages rely on it:
Understanding Go’s context Package: A Deep Dive
Go’s context package is one of the most important tools for building robust, cancellable, timeout-aware, concurrent programs. Whether you are writing HTTP servers, gRPC services, background workers, or database operations, you will almost always use context.Context.
This article provides a deep, practical, and complete analysis of the context package using clear code examples.
1. Why context Exists
Modern Go programs are highly concurrent. You might start goroutines for:
- database queries
- API calls
- background tasks
- streaming events
But how do you cancel a goroutine?
How do you propagate deadlines across function calls?
How do you attach request-scoped values safely?
Getting Started with Go: A Practical Beginner’s Guide
Go (often called Golang) is a modern programming language designed at Google. It focuses on simplicity, performance, and built-in concurrency. If you want to build fast web services, CLIs, tools, or backend systems, Go is a great choice.
This article will walk you through Go from zero to a small, working example, with plenty of code you can copy, paste, and run.
1. What is Go and Why Use It?
Go is: