Client Stream

Previous parts: Writing HTTP3 Server HTTP3 Client Server Stream Today we will create our own HTTP/3 client stream to send some sweet-sweet data to the server. Streaming data from the client can be used for sending large or real-time data uploads, such as file uploads, telemetry, or live feeds. With HTTP/3 and Go, you can efficiently stream request bodies without buffering the entire payload in memory. Streaming Client Request This is similar to streaming a request body in regular HTTP. We鈥檒l use an io.Pipe to write data from the client as it becomes available, while the server reads the stream as it arrives. ...

June 18, 2025 路 3 min

Golden Tests

Use golden files for testing APIs

June 4, 2025 路 4 min

Webview

Create desktop applications using Go and Webview, packaging them into a single executable.

May 28, 2025 路 6 min

Server Stream

Previous parts: Writing HTTP3 Server HTTP3 Client Server-side streaming allows you to send data to the client as it becomes available, rather than waiting for the entire response to be ready. This is particularly useful for applications that require real-time updates, such as chat applications, live feeds, or large file transfers. Streaming Server Response This part is similar to the regular HTTP response streaming via http.ResponseWriter. We will stream data from the server as soon as it becomes available, without buffering. For this, we will use the http.Flusher interface, which allows us to flush the response buffer to the client immediately. For reference on how to implement a basic HTTP/3 server, check out Writing HTTP3 Server. ...

May 22, 2025 路 3 min

HTTP/3 Client

Previous parts: Writing HTTP3 Server Today, we will create an HTTP/3 client to interact with our HTTP/3 Server. First of all, you鈥檒l need a running HTTP/3 server. Run it in a separate terminal: go run server.go Client skipping TLS verification Let鈥檚 write a simple HTTP/3 client for our server. It鈥檚 pretty straightforward: we need to create a new HTTP/3 transport and pass it to an HTTP client from net/http. Because HTTP/3 is built on top of QUIC, it requires us to use TLS. Since we are using a self-generated certificate in the server, the client can鈥檛 verify the certificate. One of the options is to skip TLS verification on the client: ...

May 8, 2025 路 4 min

Writing HTTP/3 Server

Today, we will go through the process of setting up a simple HTTP/3 server and verifying its functionality. We will be using quic-go for for this purpose. Generating Certificate Since HTTP/3 requires all traffic to be encrypted, we鈥檒l need a certificate. For our test, we can generate a self-signed TLS certificate for localhost. Go has a build-in tool, which you can run like this: go run $(go env GOROOT)/src/crypto/tls/generate_cert.go --host localhost $(go env GOROOT) will evaluate to the GOROOT path for whatever version of Go you are using. ...

May 8, 2025 路 4 min

Test smell

This part is mostly about gut feelings. When you are writing tests or updating the code and something feels wrong, that is a sign that this is a test smell. Tests should be your helpers; you should work with them, not against them. Tests are your guide for safe refactoring. Tests should enable refactoring, not prevent it. If it seems you are changing internals but need to rewrite the tests, the tests are not testing the behavior, but rather the implementation. ...

April 28, 2025 路 2 min

Go Links

This page is a collection of useful links about Go. Getting started Tutorial: Get started with Go - Start here. Effective Go - Continue here. Documentation Documentation - Page with links to official documentation. Managing Go installation - Installing additional Go versions. Go Wiki Go Wiki: Home - It is a collection of information about Go and a curated list of articles about Go. Go Wiki: All Wiki Pages - All articles. Selected Code Review Comments - Common mistakes and best practices when writing code. Test Comments - Common mistakes and best practices when writing tests. The Go Blog Strings, bytes, runes and characters in Go - Difference between string, []byte, rune , UTF-8 and how to iterate over them. Blog Index - All articles. Style guides Uber Go Style Guide Google Go Style Guide Containers Multi-Stage builds - Multistage builds with Go. Organizing code Organizing a Go module - Official one. Go Project Layout - It is not an official one, but it can be used to gather ideas on where to put some exotic parts of the repo. Basic structures internals How Go Arrays Work Slices in Go Go Maps Explained Golang Defer Concurrency primitives Go sync.Mutex: Normal and Starvation Mode Go sync.WaitGroup and The Alignment Problem Go sync.Pool and the Mechanics Behind It Go sync.Cond, the Most Overlooked Sync Mechanism Go Singleflight Melts in Your Code, Not in Your DB Other How I write HTTP services in Go after 13 years - Good ideas around building production quality Go HTTP services. Go Concurrency Patterns: Pipelines and cancellation - How to write a concurrent pipeline. Pipeline with errgroup package Package rheos provides generalized approach for this pattern. Ultimate Visual Guide to Go Enums and iota - All about Enums and iota. Using ldflags to Set Version Information for Go Applications - Injecting stuff during build time. v2 and Beyond - how to release a new major version: Go Modules: v2 and Beyond A pragmatic guide to Go module updates Go Error Propagation and API Contracts - TLDR; Errors are the part of your public interface too. Graceful Shutdown in Go: Practical Patterns - Handling signals for graceful shutdowns.

August 26, 2024 路 2 min