func (self *Server) Start() { fmt.Printf("Connecting to database... ") session, err := mgo.Dial("localhost") utils.HandleError(err) fmt.Println("done.") self.listener, err = net.Listen("tcp", ":8945") utils.HandleError(err) database.Init(database.NewMongoSession(session.Copy()), "mud") }
func (s *ModelSuite) SetUpSuite(c *C) { session, err := mgo.Dial("localhost") c.Assert(err, Equals, nil) if err != nil { return } dbName := "unit_model_test" _db = session.DB(dbName) session.DB(dbName).DropDatabase() database.Init(database.NewMongoSession(session), dbName) }