Writing Our Own Interfaces I
Explore how to write custom interfaces in Go by creating a Shape2D interface and implementing it with types like circles. Understand interface definition syntax, type checking, and how to use interfaces to enable sorting of 3D shapes by volume.
We'll cover the following...
We'll cover the following...
After learning about using existing interfaces, we will write another command-line utility that sorts 3D shapes according to their volumes. This task requires learning the following tasks:
Creating new interfaces
Combining existing interfaces
Implementing
sort.Interfacefor 3D shapes
Creating our own interfaces is easy. For reasons of simplicity, we include our own interface in the main package. However, this is rarely the case as we usually want ...