Conceptually, a value of an interface type, or interface value, has two components, a concrete type and a value of that type. These are called the interface’s dynamic type and dynamic value.
For a statically typed language like Go, types are a compile-time concept, so a type is not a value. In our conceptual model, a set of values called type descriptors provide information about each type, such as its name and methods. In an interface value, the type component is represented by the appropriate type descriptor.
In the four statements below, the variable
w takes on
three different values. (The initial and final values are the same.)
var w io.Writer w = os.Stdout w = new(bytes.Buffer) w = nil
Let’s take a closer ...