title: In golang, How can I override the embedded struct's method
body: <p>Code <a href="http://play.golang.org/p/lzWKavxgzr" rel="nofollow noreferrer">here</a></p>
  
  <pre><code>package main
  
  import "fmt"
  
  func main() {
      t16()
  }
  
  type Base struct {
      val int
  }
  func (b *Base)Set(i int) {
      b.val = i
  }
  type Sub struct {
      Base
      changed bool
  }
  
  func (b *Sub)Set(i int) {
      b.val = i
      b.changed = true
  }
  func t16() {
      s := &amp;Sub{}
      s.Base.Set(1)
      var b *Base = &amp;s.Base
      fmt.Printf("%+v\n", b)
      fmt.Printf("%+v\n", s)
  }
  </code></pre>
  
  <p>I want to make Sub act as Base, but when I call Set, for Sub it will mark the changed.I know there is no polymorphism or proxy in golang, but is there any way to do this, and not effect the Base?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>I hope when I call Base.Set it will mark the change, for user, they don't know they actually use the Sub, so I can monitor the Base behave.</p>
  
  <pre><code>func t16() {
      s := &amp;Sub{}
      var b *Base = &amp;s.Base
      b.Set(10)
      fmt.Printf("%+v\n", b)
      fmt.Printf("%+v\n", s)
  }
  </code></pre>