37 lines
792 B
Go
37 lines
792 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"git.mziesel.nl/mans/zadmin/database"
|
|
"git.mziesel.nl/mans/zadmin/internal/models"
|
|
"github.com/jmoiron/sqlx"
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
func main() {
|
|
db, err := sqlx.Open("postgres", "user=zadmin_user password=s3cret! dbname=zadmin_dev sslmode=disable host=localhost")
|
|
if err != nil {
|
|
log.Fatalf("goose: failed to open DB: %v\n", err)
|
|
}
|
|
|
|
defer func() {
|
|
if err := db.Close(); err != nil {
|
|
log.Fatalf("failed to close DB: %v\n", err)
|
|
}
|
|
}()
|
|
|
|
// machine, err := database.GetMachineByID(db, ulid.MustParse("01JF2RYDKKGRQSEN58S66FZ50W"))
|
|
// if err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
// fmt.Println(machine)
|
|
|
|
machines, err := database.GetAllMachines(db)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
fmt.Println(models.PrettyFormatData(machines))
|
|
}
|