Welcome to the blog!

I write about programming(mostly in Go), IT and various bits and bobs.

Enums in Go

I’ve seen many discussions about whether Go should add enum support to the language. I’m not going to bother arguing for or against but instead show how to make due with what we have in the language now. A very short enum intro Enumerated types, or enums, represent finite sets of named values. They are usually introduced to signal that variables can only take one of the predefined values for the enum....

January 26, 2024 · Vik

Streaming Netdata metrics from TrueNAS SCALE

When you install TrueNAS SCALE your NAS runs a Netdata. You can verify that by executing systemctl status netdata in the TrueNAS shell. I use Netdata to monitor my homelab and have a parent set up for long term metric storage. I’d love to configure the NAS to also push metrics to a parent, so that I can access them all from a single place. Normally, if you want to set up streaming in Netdata it’s enough to edit /etc/netdata/stream....

January 20, 2024 · Vik

SQL string constant gotcha

I was working on a project that uses PostgreSQL and as part of my task I needed to write a migration. The migrations are written as plain SQL and applied using the migrate library. The migration itself was not that complex, some rows needed to be updated where a column matched one of the values in a list. In my rush, I’ve opted for a rather simple query that went something like this:...

January 2, 2024 · Vik

Moving from Jenkins to Drone

I’ve written in the past that this blog is a playground for me to try various tools and play with code around it. Jenkins has been my choice as the CI for it since the start, mostly since it was something I’m used to. However, I’ve also stated that running it on an old laptop with no real backups is a recipe for disaster. I have since rectified the issue by hiding the laptop under a box in a closet but that meant moving away from Jenkins to something that’s lighter and more portable....

April 16, 2019 · Vik

My new server: MSI Cubi 3 Silent

I’ve recently had my birthday and as a gift decided to give myself a NUC. The intention here is that I could replace the old laptop running Jenkins and Grafana with something that’s a bit more silent and in a smaller form factor. Note that I’m not affiliated with any of the hardware manufacturers in any way shape or form. The planned change The laptop I’ve been using for Jenkins has become rather critical for this blog and a few side projects I’ve got....

April 14, 2019 · Vik

My thoughts on Ansible®

I’ve written about the infrastructure behind this blog in a previous post and the major issue with it currently is the old laptop I have at home that’s running the Jenkins instance. I really have no way of backing it all up. I’ve asked around a bit and the reddit thread I’ve made pointed me towards moving it all towards Ansible. Since people are using Ansible at work I thought it would be appropriate for me to try it as well....

February 18, 2019 · Vik

Profiling gin with pprof

Go comes with great tools for profiling out of the box. It’s one of the features I’ve come to love. I’m not going to go into detail about pprof, but if you need a primer, Julia Evans has a great post about it on her blog. Instead, I’ll try and show a real world example of the optimizations you can make using pprof. I’ll use pprof on mouthful, a gin based server, to see what I could do to make it just a bit faster....

August 23, 2018 · Vik

How I host this blog, CI and tooling

There are quite a few components to this blog now. There’s an AWS S3 bucket the blog gets served from, there’s a backend service responsible for the mouthful comments, there’s another instance of the service for the mouthful demo page, with another S3 bucket to serve the page for it. There’s also a yet unused service living in the same “cluster” as these two(It’ll get added to this blog soon™). There’s quite a few private github repositories that in unison with a Jenkins instance make this all work....

August 15, 2018 · Vik

Refactoring Go switch statements

When writing Go code, I often end up with lots of enums that I use to fork my logic in a switch statement. Take this enum: type MyEnum int const ( One MyEnum = iota Two MyEnum = iota Three MyEnum = iota Four MyEnum = iota Five MyEnum = iota )} I’ll then end up with a switch in a part of my code, like so switch myEnum { case One: err := DoSomeOtherStuff() if err !...

July 28, 2018 · Vik

OAuth with Gin and Goth

When I created mouthful, I was intending it to be rather light and not feature rich but after getting a few feature requests getting in, I’ve decided to expand it. One of the issues was a request to reuse logon credentials for the admin panel. For that, I’ve needed OAuth. I did not have much prior experience with OAuth, so it did intimidate me a bit. However, after implementing OAuth for mouthful, I can say that nowadays - it’s rather easy including OAuth in your applications as well....

June 1, 2018 · Vik