func CreateTableIfNotExists(table string) error { // Check if the table exists. cur, err := r.TableList().Run(Session) if err != nil { return err } defer cur.Close() tableName := "" for cur.Next(&tableName) { if tableName == table { return nil } } return CreateTable(table) }
func getTableList(s *r.Session) (map[string]bool, error) { cursor, err := r.TableList().Run(s) if err != nil { return nil, err } tableList := []string{} err = cursor.All(&tableList) if err != nil { return nil, err } tables := map[string]bool{} for _, table := range tableList { tables[table] = true } return tables, nil }