37 lines
555 B
Go
37 lines
555 B
Go
package slowtwitch
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
type SlowtwitchUser struct {
|
|
Username string
|
|
Password string
|
|
Email string
|
|
}
|
|
|
|
func GetUsers(db *sql.DB) []SlowtwitchUser {
|
|
rows, err := db.Query("select Username, Password, Email 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)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
users = append(users, user)
|
|
}
|
|
|
|
return users
|
|
}
|