π¨βπ» New post on Moan-routine over at Coding Bits: Zerolog’s API Mistake
Zerologβs API Mistake
I’ll be honest, I was expecting a lot more moan-routine posts than I’ve written to date. Guess I’ve been in a positive mood. That is, until I started using Zerolog again this morning.
Zerolog is a Go logging package that we use at work. It’s pretty successful, and all in all a good logger. But they made a fundamental mistake in their API which trips me up from time to time: they’re not consistent with their return types.
When you want to create a new logger, you get a zerolog.Logger
instance. This is also returned when you’re creating a new logger from an existing one, say with some extra string attributes. All good. But, when you want to retrieve a logger from the context, it returns a *zerolog.Logger
instance.
This makes it difficult to write functions that accept logger instances from arbitrary sources. If there’s any chance that you need to supply a logger from a context, you find yourself writing parameters with the *zerolog.Logger
type. But that makes passing in new logs annoying, as you’d have to instantiate the log into a variable, then pass that variable address through. You could use zerolog.Logger
instead, but then you’ve got the opposite problem, where you’ll need to dereference the logger returned from the context.
In short, this is impossible:
func myFunc(log ???) {
// do something
}
myFunc(zerolog.New(os.Stderr))
myFunc(zerolog.Ctx(ctx))
And yeah, in the grand scheme of things, this is not a huge mistake. And usually I’m passing in logs exclusively from the context, so *zerolog.Logger
works just fine most of the time. But I’m never comfortable with deciding which is the right type to use, and when I get it wrong, and I resort to using temporary variables, it just leaves the code looking untidy.
So please, when you’re writing an API that returns a specific entity, be consistent in your types. Either return the struct itself, or the pointer. I don’t care which one you use, but please, just choose one.
Got a long post written that I wanted to publish today. But I need to add the audio narration to it, and my voice is just not working this evening. So I’m going to have to hold it for a bit longer. A shame, but if a day late means a better overall post, it might be worth it in the end.
The gym has discovered they have a heater, which is immensely welcomed, because wearing shorts and a T-shirt in weather that’s barely 16Β°C is not fun (and this is the warmest it’s been in weeks). π₯Ά
π On the origins of DS_store
An interesting tale on how .DS_Store
β a regular in Git ignore files everywhere β got its name.
Via @Burk within the Hemispheric Views Discord.
Woke up with this tune in my head this morning. Managed to record it before I forgot it, then I added some accompaniments. I’ve called it Prophet, after the synth. It’s a decent start but I’m not sure how to continue it from this point on.
Added the final pieces of my self-hosted Forgejo instance this morning: a MacOS runner, and daily backups. I think weβre finally ready to start using it for current projects now.
π txt.fyi
Thank you to the anonymous person who runs this. Something happened which left me ropeable, and I needed a place to scream into the void. I did it there. It’s now lost to the either, along with (most) of my anger. Hopefully time will fix what’s left.
A Bit of 'Illuminating' Computer Humour
Hereβs some more computer-related humour to round out the week:
How many software developers does it take to change a lightbulb? Just one.
How many software developers does it take to change 2 lightbulbs? Just 10.
How many software developers does it take to change 7 lightbulbs? One, but everyone within earshot will know about it.
How many software developers does it take to change 32 lightbulbs? Just one, provided the space is there.
How many software developers does it take to change 35 lightbulbs? Just one. #lightbulbs
How many software developers does it take to change 65 lightbulbs? Just one, if they’re on their A grade.
How many software developers does it take to change 128 lightbulbs? Just one, but they’ll be rather negative about it.
How many software developers does it take to change 256 lightbulbs? What lightbulbs?
Enjoy your Friday.

Just bought Crystal Caves HD from GoG. This might be the best $4.00 I spend today. π
Mark the date. First successful CI/CD run of a Go project running on my own Forgejo instance, running in Hetzner. π

Some day, I’ll be working on a task I’d be pressured to get finished right then and there, and no one will be messaging me while I’m doing it. Today was not that day. π¨βπ»π³
Last night, I setup a Linode server to try out Forgejo. The setup went smoothly, and I managed to get Forgejo up and running, but the setup is a little expensive: around ~$18.00 AUD for a 2 GB server with 50 GB storage. So I’m going to try out Hetzner. I should, in theory, be able to get two servers β one for the frontend, and one as a CI/CD worker β both with twice as much RAM, plus a 50 GB volume for around ~$17.00 AUD.
The only downside is that the servers are further away: Falkenstein, Germany; rather than Sydney (I can’t be the only one that wishes the speed of light was faster). We’ll see how much the latency’s going to annoy me.
Ok, going to try out Forgejo for self-hosting my code. Got through the hardest part, which was paying for a Linux VPS (with backups enabled) and I’ll start with some old repositories that I won’t feel bad loosing. But if it all works out, I’ll use it as my replacement for Github. Wish me luck. π€

I’m enjoying the special guests on Downstreamβ¦ but I do miss Julia. I mean, I’m super happy for her career advancement which led to her departure, but she and Jason were a great podcasting duo. But it’s fine, the special guests are great too. Currently listening to the episode with Tim Goodman.
I wish more podcasters know what a double-ended podcast is. Having Zoom’s compression algorithm garble your most important point is not a great listening experience. If you’re just starting off, or if you have a guest, that I understand. But if you’ve been doing this for years as part of your job? π«€
There are times where I wish Go had Python-like tuples, but I think the decision to keep them out of the language is a good one. I feel like it’s easy for people to overuse these types of tuples, instead of coming up with new dedicated types. Go isn’t completely immune from this β I’ve seen some functions returning slices of slices of strings β but it does try to encourage writing code with many different types, each one with a narrow use case. The fact that this is found both in the culture and in the language itself (e.g. anonymous structs) is a good thing.
A university text-book author walks into a bar. The punchline is left as an exercise for the reader.
A QA walks into a bar, crawls into a bar, flys into a bar; and orders: a beer, 2 beers, 0 beers, -1 beers, then walks out saying “Test complete.” Meanwhile, a software developer asked to do QA walks into a bar and says “I didn’t fall down walking in. Test complete.”
Ran into my old barista this morning. He made morning coffees at the station in the late 2010s, before Covid wiped his business out. I thought heβd headed back to New Zealand after that, but no heβs still around and doing quite well (just not morning coffees). Really great to see him again. βοΈ