Sobes.tech
Senior

To which group (mutable/immutable) does the interface in Go belong?

sobes.tech AI

Answer from AI

In Go, an interface is a type that describes a set of methods, but it does not contain data itself. An interface in Go is immutable in the sense that once an interface value is created, the set of methods it describes cannot be changed. However, an interface value can hold a pointer to a mutable object, and through the interface methods, the internal state of this object can be modified.

Thus, as a type, an interface is immutable, but the objects it describes can be mutable.