Paul's page
Hacker, tech-entrepreneur
log/slog is no longer new in Go. It was introduced in 2023 with Go 1.21. But it is very nice for structural logging. Here’s how to make that structural logging work better for you:
So much of what we develop these days ends up using HTTP. Usually when developing an HTTP service it’s quite easy to add logging to aid debugging. But when developing a client, especially one that uses a library which does the actual HTTP calls, it can be harder to insert logging in all the right places.
Docker Hub has announced new pull limits starting 2024-04-01. An easy way to get around that is to set up a pull-through cache. This can easily be done using CNCF Distribution. Here’s how I did that on NixOS:
Searching for VictoriaLogs on search.nixos.org gave me no results, so I ran victorialogs from Docker. But at some point I did search for victorialogs on nixpkgs and realized that the binary is built with victoriametrics.
Go includes a safe and somewhat performant templating library. But the best way to structure code using html/template has eluded me for a long time.
VictoriaLogs looks like an interesting alternative to Grafana Loki. But it would be nice to still query it via the Grafana Dashboard along with all the rest. It takes a couple of specific steps to install the appropriate plugin, especially on NixOS.
There are several nice options in NixOS for specifying scheduled backup jobs, including borgbackup, borgmatic and restic. But I’ve often used rsync in the past, and there is no such module for scheduled rsync jobs (or rsnapshot either). So I wrote my own simple module.
There has been a lot of talk in recent years how running your own email server is too hard. But it’s quite healthy for the email ecosystem to not have everyone use Gmail and Outlook. In my experience it isn’t too hard, just takes some work.
Caddy is a very handy HTTP server with lots of built-in features. But every once in a while you need something more. Fortunately Caddy has a plugin API. But Caddy being written in Go, the plugins need to be added at compile-time. On NixOS, there are no plugins added by default, and there are a couple of things to note when adding them.
Go error handling can be a bit verbose. There are a lot of places where errors are unlikely or where they are so critical that a panic is preferred. Because of this there are lots of Must* -helpers in various packages. E.g. regexp.MustCompile.