メモメモ embedded field

<- http://golang.org/ref/spec#Struct_types

Struct types

//

A field declared with a type but no explicit field name is an anonymous field, also called an embedded field or an embedding of the type in the struct

//

// !

Given a struct type S and a type named T, promoted methods are included in the method set of the struct as follows:

  • If S contains an anonymous field T, the method sets of S and *S both include promoted methods with receiver T. The method set of *S also includes promoted methods with receiver *T.
  • If S contains an anonymous field *T, the method sets of S and *S both include promoted methods with receiver T or *T.