Skip to content

Instantly share code, notes, and snippets.

@rikonor
Created January 11, 2017 18:37
Show Gist options
  • Save rikonor/9d0b0f077d0ae86d5395fade29b644ca to your computer and use it in GitHub Desktop.
Save rikonor/9d0b0f077d0ae86d5395fade29b644ca to your computer and use it in GitHub Desktop.
Mocker calling itself
package main
import "fmt"
func main() {
d := &MockDoer{}
d.DoFn = func() {
fmt.Println("Do")
d.AlsoDo()
}
d.AlsoDoFn = func() {
fmt.Println("AlsoDo")
}
var dd Doer = d
dd.Do()
}
type Doer interface {
Do()
AlsoDo()
}
type MockDoer struct {
DoFn func()
AlsoDoFn func()
}
func (d *MockDoer) Do() {
d.DoFn()
}
func (d *MockDoer) AlsoDo() {
d.AlsoDoFn()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment