Interfaces
Learn about interfaces in Go.
We'll cover the following...
We'll cover the following...
Checking if an interface variable is nil
This is certainly one of the most common traps in Go. An interface in Go is not simply a pointer to a memory location as in some other languages.
An interface has:
- A static type (the type of the interface itself)
- A dynamic type
- A value
Note: A variable of an interface type is equal to nil when both its dynamic type and value are nil.”
The interface value is set to a nil struct. The interface can’t be used
for anything, so why isn’t it equal to nil? This is another ...