interface value
A value held in an interface variable, which carries two parts: the concrete type it really is and the value itself.
In more detail
The interface's static type decides which methods you can call directly; the dynamic type is what is actually inside. An interface is nil only when both parts are empty. Type assertions and type switches read the dynamic type.
Related terms
- interface — A named set of member signatures that a type promises to implement, with no state of its own.
- type assertion — An expression such as value.(string) that gets the concrete value out of an interface, if it really holds that type.
- concrete type — An actual type with its own data, such as string or a Target struct, as opposed to an interface that only describes behaviour.
- nil — The Go value meaning nothing or not set, which is the zero value for pointers, slices, maps, channels, functions, interfaces and errors.
Taught in
- Type Assertions and the Empty Interface — Concurrent Systems Programming with Go