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 ...