Golang’s Interfaces Explained with Mocks

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Yes, You Can Learn SQL In Two Hours

How I Navigate Online Learning

How QA Is Playing A Significant Role In Digital Transformation

The Gates of Code Quality — Pylint

Explore API Priority and Fairness to Ease the Load of the APIServer

TWiGCP — “Anthos on bare metal, Container Threat Detection, and Traffic Director beyond the cloud”

How to Calculate ROI For Test Automation

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

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

More from Medium

Websockets — Is it still useful?

LeetCode Two Sum With Go

Coltrane and Kadane — How We Can Apply Lessons from Legends to Improve our Coding Craft

What is Protobuf and Why You Should Use It