Compare commits

...

2 Commits

Author SHA1 Message Date
7fd104b6d0 feat: call godotenv 2025-05-18 20:20:30 +02:00
abddaaf51a feat: example .env file 2025-05-18 20:20:23 +02:00
2 changed files with 19 additions and 0 deletions

12
.env.example Normal file
View File

@ -0,0 +1,12 @@
DATABASE_URL="postgres://<user>:<user>@<host>:<port>/<db>?sslmode=disable"
ADMIN_NAME="admin"
ADMIN_EMAIL="admin@test.net"
ADMIN_PASSWORD="secret"
GOOSE_DRIVER="postgres"
GOOSE_DBSTRING=$DATABASE_URL
GOOSE_MIGRATION_DIR="./migrations"

View File

@ -9,9 +9,16 @@ import (
"gitea.local/admin/hspguard/internal/repository"
"gitea.local/admin/hspguard/internal/user"
"github.com/jackc/pgx/v5"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatalln("ERR: Failed to load environment variables:", err)
return
}
ctx := context.Background()
conn, err := pgx.Connect(ctx, os.Getenv("DATABASE_URL"))