Golang’s Interfaces Explained with Mocks

Benjamin Cane
The Startup
Published in
5 min readFeb 16, 2021

When I was learning Golang, one of the concepts that took me the most time to grasp was Interfaces. Golang’s Interfaces are a great way to make modular and testable code. But they can also be a bit confusing at first glance.

One of the best ways I’ve found to teach how interfaces work is by creating a mock implementation of an existing Interface.

Benjamin Cane
The Startup

Building payments systems at American Express. Author (https://amzn.to/3kuCFpz). Open-source contributor (https://github.com/madflojo).