func initMongoIndex() *index.Index { // connect without credentials and wipe the database mgw := &mongo.MongoWrapper{ Servers: "localhost", Database: "camlitest", Collection: "keys", } idx, err := mongo.NewMongoIndex(mgw) if err != nil { panic(err) } err = idx.Storage().Delete("") if err != nil { panic(err) } // create user and connect with credentials err = mongo.AddUser(mgw, "root", "root") if err != nil { panic(err) } mgw = &mongo.MongoWrapper{ Servers: "localhost", Database: "camlitest", Collection: "keys", User: "******", Password: "******", } return idx }
func initMongoIndex() *index.Index { mgw := &mongo.MongoWrapper{ Servers: "localhost", Database: "camlitest", Collection: "keys", } idx, err := mongo.NewMongoIndex(mgw) if err != nil { panic(err) } err = idx.Storage().Delete("") if err != nil { panic(err) } return idx }