- Hands-On System Programming with Go
- Alex Guerrieri
- 98字
- 2021-06-24 13:42:20
Composite types
Beside the basic types, there are others, which are known as composite types. These are as follows:
The empty interface, interface{}, is a generic type that can contain any value. Since this interface has no requirements (methods), it can be satisfied by any value.
Interfaces, pointers, slices, functions, channels, and maps can have a void value, which is represented in Go by nil:
- Pointers are self-explanatory; they are not referring to any variable address.
- The interface's underlying value can be empty.
- Other pointer types, like slices or channels, can be empty.