© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
B. Feigenbaum, Ph.D.Go for Java Programmershttps://doi.org/10.1007/978-1-4842-7199-5_9

9. Applications for Interfaces

Barry Feigenbaum, Ph.D.1  
(1)
Austin, TX, USA
 

In this chapter, we will discuss some interesting applications of interfaces in Java and how they relate to Go coding.

An Interface Is the Key

Just like in Java, using interfaces (over concrete types) as parameter and return types is important in Go. It enables many options, such as substituting mock objects1 for normal objects, which is critical for testing. So, especially when you pass a struct type into or out of a function, see if you can replace the struct with an interface type. This is generally ...

Get Go for Java Programmers: Learn the Google Go Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.