I have following (untested) function:
func Execute(task MyInterface) {
db := session.DB(task.Database()).C(task.Collection())
var tasks []MyInterface
db.Find(nil).All(&tasks)
for _, t := range tasks { t.Do() }
}
I want to give my function a struct that implements interface MyInterface
. It should then retrieve some values from mongodb and call a method on the retrieved structs.
Problem is error: reflect.Set: value of type bson.M is not assignable to type mypkg.MyInterface
- is there some way to make this work? I tried to instantiate tasks
using the type of the original struct, but couldn't get it working.
Any help would be appreciated - thanks :)