Golang’s Interfaces Explained with Mocks

Photo by Phil Hearing on Unsplash

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Benjamin Cane

Benjamin Cane

423 Followers

Distinguished Engineer @AmericanExpress building payments systems. Author: https://amzn.to/3kuCFpz, Thoughts, & Opinions are my own.