From the specification:
A nested type must be specified as a type name T or as a pointer to a type name without an * T interface, and T itself cannot be a pointer type.
You see that he mentions a "type name".
Named types are indicated by a (possibly qualified) type name; unnamed types are specified using a type literal that represents a new type from existing types.
In other words, a map or slice can be anonymous if they are not defined as a named type. For instance:
type MyMap map[string]string type customMap struct{ MyMap ordered []string }
However, even if you insert a MyMap or slice type, you still cannot index customMap. Only fields and methods can be "advanced" in embedding. For everything else, they act like just another field. In the above example, MyMap has no fields or methods and is therefore equivalent:
type customMap struct{ MyMap MyMap ordered []string }
source share