An interface is two things: it is a set of methods, but it is also a type.

When you first learn Go, interface is always introduced as a common methods for some types.

A lesser known feature is that interface{} is a type - the empty interface with no methods. Therefore all types have already implemented interface{}.

One good use is in map[string]interface{} - where the key is string and the value is any type. You can read more about interface values.




Back to Home