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