sbstp’s blog

Go FuncCloser pattern

I’ve run quite a few times into this issue lately. I have an io.Reader which wraps another io.Reader but does not offer a way to close the inner io.Reader. One instance of this issue is with the bufio.Reader type. The function below opens the given file, peeks at the first 512 bytes to try to detect the mime type, and then returns an io.ReadCloser to read and then close the file....

August 15, 2023

Running pihole on a VPS securely

I’ve been running pihole on my NAS for a while. My router is configured to use the NAS as its primary DNS, meaning all the devices on my network get configured to use the pihole resolver. Running it on my NAS server is not ideal though, because when I do maintenance on the NAS, all the devices on the network start having issues because the DNS resolver is down. I’ve tried providing a secondary DNS resolver to my router for cases like this, but it ends up making pihole useless because ads are able to get through on the devices even when the primary resolver is up....

September 18, 2022

Introducing Kubie

Kubie is a tool that I’ve created to improve my day to day life at work. I work with a lot of kubernetes clusters: I have around two dozen clusters in my config files. I also happen to multitask a lot. I use the i3 window manager to keep my work organized, often having 7 or 8 different workspaces active at once. I kept being bothered by the fact that kubectx and kubens modify a global config file....

March 31, 2020

Go Quirks

I’ve recently started working with Go on a full time basis. It’s a fun language to use, and it comes with a rich standard library. Shipping a production ready HTTP server in the standard library is no small feat. It’s not free from issues and quirks though. In this post, I’ll discuss some of the issues and quirks I’ve encountered in my journey with Go. I’ve deliberately chosen to not talk about often raised issues such as the lack of generics and the err !...

March 28, 2020