add reading configs
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-09-23 23:19:10 +02:00
parent a0ad4e5c26
commit ba83d70764
6 changed files with 116 additions and 24 deletions
+7 -7
View File
@@ -4,8 +4,8 @@ import (
"fmt"
"log"
"log/slog"
"os"
"time"
"github.com/spf13/viper"
"gorm.io/driver/postgres"
"gorm.io/gorm"
@@ -18,12 +18,12 @@ func Connect() {
// Build the connection string from environment variables
// This keeps sensitive credentials out of the codebase
dsn := fmt.Sprintf(
"host=%s user=%s password=%s dbname=%s port=%s sslmode=disable",
os.Getenv("DB_HOST"),
os.Getenv("DB_USER"),
os.Getenv("DB_PASSWORD"),
os.Getenv("DB_NAME"),
os.Getenv("DB_PORT"),
"host=%s user=%s password=%s dbname=%s port=%d sslmode=disable",
viper.GetString("db.host"),
viper.GetString("db.user"),
viper.GetString("db.password"),
viper.GetString("db.name"),
viper.GetInt("db.port"),
)
// Configure GORM with custom settings