package communication import ( "fmt" ) type SerialInterface struct { phy physical } func NewSerialInterface() (SerialInterface, error) { iface := SerialInterface{} var err error iface.phy, err = newPhysical() if err != nil { return iface, err } return iface, nil } func (i *SerialInterface) Start() { i.phy.start() } func (i *SerialInterface) Cat() { for { data := <-i.phy.rx fmt.Printf("%s", string(data)) } }