github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2015/go4cpp/diamond.go (about)

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import "fmt"
     6  
     7  type Engine struct{}
     8  
     9  func (e Engine) Start() { fmt.Println("Engine started") }
    10  func (e Engine) Stop()  { fmt.Println("Engine stopped") }
    11  
    12  type Radio struct{}
    13  
    14  func (r Radio) Start() { fmt.Println("Radio started") }
    15  func (r Radio) Stop()  { fmt.Println("Radio stopped") }
    16  
    17  type Car struct {
    18  	Engine
    19  	Radio
    20  }
    21  
    22  func main() {
    23  	var c Car
    24  	c.Radio.Start()  // HL
    25  	c.Engine.Start() // HL
    26  }