Recap: Reflection and Interfaces

Let’s look at a chapter summary and take a short quiz to test our understanding of this chapter’s content.

Summary

In this chapter, we learned about interfaces, which are like contracts, and also about type methods, type assertion, and reflection. Although reflection is a very powerful Go feature, it might slow down our Go programs because it adds a layer of complexity at runtime. Furthermore, our Go programs could crash if we use reflection carelessly.

The last lessons of this chapter discussed writing Go code that follows the principles of object-oriented programming. If we are going to remember just one thing from this chapter, it should be that Go is not an object-oriented programming language, but it can mimic some of the functionality offered by object-programming languages, such as Java, Python, and C++.

Quiz on reflection and interfaces

Get hands-on with 1200+ tech skills courses.