Skip to content

Instantly share code, notes, and snippets.

@pallat
Last active August 29, 2015 14:10
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 pallat/8ae56e21a33ba159d5cf to your computer and use it in GitHub Desktop.
Save pallat/8ae56e21a33ba159d5cf to your computer and use it in GitHub Desktop.
package main
type presenter interface {
method() interface{}
}
type doing func() interface{}
func (d doing) method() interface{} {
return d()
}
func mocking(d doing, p presenter) presenter {
if d == nil {
return p
}
return d
}
type actor struct {
name string
}
func (a *actor) method() interface{} {
println("actor method")
return "actor"
}
var mock = func() interface{} {
println("mock method")
return "mock"
}
func main() {
var p presenter
p = new(actor)
p.method()
p = mocking(mock,p)
p.method()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment