package main func getEvents() []event { db := ctdoConnect() defer dbClose(db) rows := dbQuerry(db, "SELECT * FROM events;") events := []event{} for rows.Next() { Event := new(event) err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date) if err != nil { panic(err.Error()) } events = append(events, *Event) } return events } func getEventCount() int { db := ctdoConnect() defer dbClose(db) row := dbQuerry(db, "SELECT COUNT(*) FROM events;") count := 0 for row.Next() { row.Scan(&count) } return count } func addEvent(Event event) bool { db := ctdoConnect() defer dbClose(db) if len(Event.title) > 80 || len(Event.description) > 500 || len(Event.media) == 10000 || len(Event.date) > 10 { return false } sqlString := "insert into events (title, description, media, date) values ('" + Event.title + "', '" + Event.description + "', '" + Event.media + "', '" + Event.date + "');" dbQuerry(db, sqlClean(sqlString)) return true } func getAdminKeys() []string { db := ctdoConnect() defer dbClose(db) rows := dbQuerry(db, "select * from adminKeys;") output := []string{} for rows.Next() { temp := "" err := rows.Scan(&temp) if err != nil { panic(err.Error()) } output = append(output, temp) } if len(output) == 0 { return nil } return output }