TIL
Embedded field in Go
- 1 minutes read - 56 words- Initializing embedded field: The field name of an anonymous field during a struct instantiation is the name of the struct (Time)
type Event struct {
ID int
time.Time
}
event := Event{
ID: 1234,
Time: time.Now(),
}
- If an embedded field type implements an interface, the struct containing the embedded field will also implement this interface