How to understand the following struct definition?

import (

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?


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.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.