package slowtwitch import ( "database/sql" "fmt" ) type SlowtwitchCategory struct { Id int Name string FullName string FatherId int CatDepth int NumberOfLinks int } func GetCategories(db *sql.DB) []SlowtwitchCategory { rows, err := db.Query("select ID, Name, Full_Name, FatherID, CatDepth, Number_of_Links from glinks_Category;") if err != nil { fmt.Println(err) } defer rows.Close() var categories []SlowtwitchCategory for rows.Next() { category := SlowtwitchCategory{} err := rows.Scan(&category.Id, &category.Name, &category.FullName, &category.FatherId, &category.CatDepth, &category.NumberOfLinks) if err != nil { fmt.Println(err) } categories = append(categories, category) } return categories }