Testing shell commands in Go

A standard way of running shell commands in Go is via exec.Command. However, calling this function directly within your business logic makes the code hard to test. This post demonstrates an approach I developed when I had to adapt my code for running shell commands both locally and remote over SSH, while also keeping it testable. TL;DR: extract exec.Command into an interface and create a mock implementation for testing. Implement it for your SSH client too, if needed.

Byobu, a simple terminal multiplexer

I am not a proponent of highly customized development environments. During the years, I’ve tried employing various “advanced” tools and tricks in my workflow: zsh, all sorts of terminals, shortcuts, aliases, and so on. Most of them didn’t stick. In most cases, I’m not interested enough to change the ways and habits for something that is supposed to marginally improve my everyday work, doesn’t come by default, and requires extra configuration.

But it works on my machine

It is mostly acknowledged that developers should be responsible for their code on every stage of its lifecycle. Despite that, some think that having a code work on their machine is enough to consider a job to be done, or that fixing and preventing issues in production is none of their business. The others are simply unaware of the complexities of real world and of the differences between a production environment and their local setup. This post is mostly for and about the latter.

Make CapsLock useful (again) on Linux and Windows

TL;DR: Use this repository to remap the CapsLock key and move your hands around the keyboard more effectively.

Setting up development environment with docker

Road highlighting on a map with Overpass

For a recent project at one of my courses, we had a requirement to highlight a road segment on a map at any given point. In a search for a ready-to-use database or API with road coordinates, I’ve found Overpass. It’s a part of an OpenStreetMap project that provides OSM map data over API, and has a feature to get roads around given point, which is exactly what was needed. Try the demo right away or proceed reading the article on implementation details.