func doit() error { log.Printf("Removing existing data storage and cache...") if err := dbprep.ClearCache(); err != nil { return fmt.Errorf("Couldn't clear cache: %v", err) } if !*initialize { if err := dbprep.RemoveData(); err != nil { return fmt.Errorf("Couldn't clear database storage: %v", err) } } if !*clear { log.Printf("Intializing data storage...") if err := dbprep.EnsureData(); err != nil { return fmt.Errorf("Couldn't clear storage: %v", err) } } log.Printf("Done.") return nil }
func Connect() (cacheId, databaseId string, err error) { // make sure the database is initialized if err = dbprep.EnsureData(); err != nil { err = fmt.Errorf("Couldn't initialize database: %v", err) return } rdInit() rdMutex.Lock() defer rdMutex.Unlock() cacheId, err = rdConnect() if err != nil { return } pgInit() databaseId, err = pgConnect() if err != nil { return } return }