func InitDb() (*mgo.Session, error) { env := config.GetEnvValue() mongoDBDialInfo := &mgo.DialInfo{ Addrs: []string{env.Database.Host}, Timeout: 60 * time.Second, Database: env.Database.Name, Username: env.Database.User, Password: env.Database.Password, } if mongoSession != nil { panic("mongodb is connected!") } var err error if mongoSession, err = mgo.DialWithInfo(mongoDBDialInfo); err != nil { return mongoSession, err } dataBase = env.Database.Name return mongoSession, Index() }
func Start() error { app := setup() env := config.GetEnvValue() return app.Run(env.Server.Host + ":" + strconv.Itoa(env.Server.Port)) }