Last active
August 8, 2016 14:52
-
-
Save wyattjoh/90c5ffde287e9efd1628e4602c587b64 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
type Database interface { | |
Execute(c *mgo.Collection) error | |
} | |
type Result struct{} | |
func MyService(db Database) (*Result, error) { | |
var result Result | |
f := func(c *mgo.Collection) error { | |
return c.Find(query).One(&result) | |
} | |
if err := db.Execute(f); err != nil { | |
return nil, err | |
} | |
return &result, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment