Go Interfaces Types

January 10, 2021   

Notes from: https://blog.golang.org/laws-of-reflection

GoLang’s Interface Type**

An interface type is a type which represents a fixed set of methods.

An interface variable can store any concrete (non-interface) value as long as that value implements the interfaces methods.

Whatever concrete value an interface variable may hold the interface variable’s type matches what it was declared as.

The empty interface: interface{} represents the empty set of methods and is statisfied by any value at all. Since any value has zero or more methods.

Go’s interfaces are NOT dynamically typed. They are statically typed: A variable of interface type always has the same static type. Even though at run time the value stored in the interface variable my change the type it will always satisfy the interface.