How to understand the following struct definition?

import (
“tool/unit”
)

type Unit struct {
*unit.Unit // Unit is defined in unit package, but there is no variable name
SubNumEng int
SubNumber int
input1 Port
input2 Port
Output Port
}

Have question about the unit.Unit definition in the structure, all other definitions include both type and variable name, but there is no variable name for pointer *unit.Unit, wonder what does this mean?

Hi,

this is the case of “struct embedding”; this means that your struct contains all the field of the unit.Unit one.

Read here for more details

@Massimo.Costa, Thanks for answering the question. I really appreciate it.