Standard Search
About 99 results
https://rednafi.com/go/io-reader-signature/ · 8 Feb 2025
Understand why io.Reader takes a byte slice parameter instead of returning one. Learn about heap allocations and buffer reuse in Go streams.
https://rednafi.com/go/slice-gotchas/ · 6 Feb 2025
Avoid common Go slice mistakes: shared backing arrays, nil vs empty slices, append behavior, and slice copying pitfalls explained.
https://rednafi.com/misc/run-single-instance/ · 31 Dec 2024
Prevent multiple script instances with file locking. Use flock in Bash, fcntl in Python, and syscall.Flock in Go for single-instance processes.
https://rednafi.com/go/func-types-and-smis/ · 22 Dec 2024
Implement single-method interfaces with function types instead of structs. Master http.HandlerFunc patterns for middlewares, mocks, and adapters.
https://octet-stream.net/b/tt/go-template-functions.html · 12 Nov 2024
HOME BLOGS PROJECTS GITHUB 12 November 2024 Recently I wanted to add a function to the data object for a Go template which would allow me to generate some parts dynamically. Here's what my first attempt looked like. For a template like this: ...
go
https://octet-stream.net/b/scb/watch-channel-in-go.html · 8 Nov 2024
8 November 2024 In this post I want to share a design pattern for a simple broadcast/watch channel in Go. I'm a relative golang newcomer and I've been learning how to do certain things that I already have a solution for in Rust—in this case tokio's wat...
https://rednafi.com/go/topological-sort/ · 13 Oct 2024
Implement topological sorting in Go to order tasks by dependencies. Process directed acyclic graphs for build systems and scheduling.
https://rednafi.com/go/circuit-breaker/ · 6 Oct 2024
Build a production-ready circuit breaker in Go from scratch with closed, open, and half-open states to prevent cascading failures.
https://rednafi.com/misc/etag-and-http-caching/ · 10 Apr 2024
Implement client-side HTTP caching with ETag headers. Learn If-None-Match, 304 Not Modified responses, and weak validation in Go servers.
https://rednafi.com/misc/crossing-the-cors-crossroad/ · 12 Mar 2024
Troubleshoot CORS errors with this practical guide. Learn Access-Control-Allow-Origin headers, preflight requests, and domain allowlisting in Go.