Post-Migrator/services/slowtwitch/get-users.go

38 lines
590 B
Go
Raw Normal View History

package slowtwitch
import (
"database/sql"
"fmt"
)
type SlowtwitchUser struct {
Username string
Password string
Email string
Name string
}
func GetUsers(db *sql.DB) []SlowtwitchUser {
rows, err := db.Query("select Username, Password, Email, Name from glinks_Users;")
if err != nil {
fmt.Println(err)
}
defer rows.Close()
var users []SlowtwitchUser
for rows.Next() {
user := SlowtwitchUser{}
err := rows.Scan(&user.Username, &user.Password, &user.Email, &user.Name)
if err != nil {
fmt.Println(err)
}
users = append(users, user)
}
return users
}