Skip to content

Instantly share code, notes, and snippets.

@wyattjoh
Last active August 8, 2016 14:52
Show Gist options
  • Save wyattjoh/90c5ffde287e9efd1628e4602c587b64 to your computer and use it in GitHub Desktop.
Save wyattjoh/90c5ffde287e9efd1628e4602c587b64 to your computer and use it in GitHub Desktop.
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