fix: macos fix can't open the app

This commit is contained in:
2024-11-16 05:36:54 +07:00
parent ad8b67ccd3
commit b88b04a235
3 changed files with 35 additions and 13 deletions
+1 -8
View File
@@ -2,7 +2,6 @@ package db
import (
"log"
"os"
"strings"
"gorm.io/driver/postgres"
@@ -19,15 +18,9 @@ func Get() *gorm.DB {
return dbInstance
}
func Init() {
func Init(dsn string) {
// log.Println("Initializing database...")
dsn := os.Getenv("DATABASE_URL")
if dsn == "" {
// WAL: _journal_mode=WAL
dsn = "file:data.db?cache=shared&mode=rwc"
}
// Open db connection
var con gorm.Dialector
if strings.HasPrefix(dsn, "postgres:") {