Subscribe to the Ardan Labs Insider

You’ll get our FREE Video Series & special offers on upcoming training events along with notifications on our latest blog posts.

Included in your subscription
  • Access to our free video previews
  • Updates on our latest blog posts
  • Discounts on upcoming events

Valid email required.

Submit failed. Try again or message us directly at

Thank You for Subscribing

Check your email for confirmation.

Interfaces 101 : Error Handling With Go Ep. 3

Author image

Ardan Labs


In episode 2, Miki examined the impact interfaces have on the performance of a Go program. To perform this experiment, Miki invoked a type’s method in two ways: with the concrete type and as an interface function to measure the difference in execution time. The conclusion of this experiment was that calling a method with the concrete type is faster than using an interface. During the experiment, Miki made use of the build flag -gcflag=’-m’ to display which variables were being allocated on the heap and where the compiler was automatically inlining function calls.

In this video, Miki will take a look at the error interface and how to define a type to satisfy it. The first step Miki takes is to implement a custom type with a method named Error that returns a string. Once the interface is satisfied, Miki will write a test that will invoke a function that returns his custom error type and verify if the returned value does not equal to nil, if so, the test fails. The odd thing here is that the test fails although Miki does not set a value for the returned error. Watch and learn how to properly define a type that implements Go’s error interface.

Things you will learn in this video

  • Implement Go’s error interface.
  • How does Go determine if an error value is nil.
  • How to avoid false-positives with custom implementations of error interface.


Go Training

We have taught Go to thousands of developers all around the world since 2014. There is no other company that has been doing it longer and our material has proven to help jump start developers 6 to 12 months ahead of their knowledge of Go. We know what knowledge developers need in order to be productive and efficient when writing software in Go.

Our classes are perfect for both experienced and beginning engineers. We start every class from the beginning and get very detailed about the internals, mechanics, specification, guidelines, best practices and design philosophies. We cover a lot about "if performance matters" with a focus on mechanical sympathy, data oriented design, decoupling and writing production software.

Capital One
Red Ventures

Interested in Ultimate Go Corporate Training and special pricing?

Let’s Talk Corporate Training!

Join Our Online
Education Program

Our courses have been designed from training over 30,000 engineers since 2013, and they go beyond just being a language course. Our goal is to challenge every student to think about what they are doing and why.