Created
January 11, 2017 18:37
-
-
Save rikonor/9d0b0f077d0ae86d5395fade29b644ca to your computer and use it in GitHub Desktop.
Mocker calling itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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