-
Book Overview & Buying
-
Table Of Contents
Go Programming - From Beginner to Professional - Second Edition
By :
An interface is a set of methods that describe the behavior of the data type. Interfaces define the behavior(s) of the type that must be satisfied to implement that interface. A behavior describes what that type can do. Almost everything exhibits certain behavior. For example, a cat can meow, walk, jump, and purr. All of those are behaviors of a cat. A car can start, stop, turn, and speed up. All of those are behaviors of a car. Similarly, behaviors for types are called methods.
Note
The definition that the official documentation provides is Interfaces in Go provide a way to specify the behavior of an object. (https://go.dev/doc/effective_go#interfaces_and_types)
There are several ways to describe an interface:
Speaker{} interface:type Speaker interface {
&...