Skip to content

Instantly share code, notes, and snippets.

@hooluupog
Created September 29, 2017 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hooluupog/fd9cbe0a68e54c331b7bf5988054122b to your computer and use it in GitHub Desktop.
Save hooluupog/fd9cbe0a68e54c331b7bf5988054122b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type DoInter interface {
Do()
Get() DoInter
Set()
}
/////////////////////////////
type A struct {
i DoInter
}
func (b *A) Do() {
fmt.Println("aaa")
}
func (b *A) Get() DoInter {
return b.i
}
func (b *A) run() {
for i := 0; i < 10; i++ {
b.Get().Do()
}
}
//////////////////////////////////
type B struct {
A
}
func (b *B) Do() {
fmt.Println("bbbbb")
}
func (b *B) Set() { b.i = b }
func main() {
b := B{}
b.Set()
b.run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment