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.