feat: add db management scripts
This commit is contained in:
34
internal/config/main.go
Normal file
34
internal/config/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type dbConfig struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
func loadEnv() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Println("Warning: could not load .env file")
|
||||
}
|
||||
}
|
||||
|
||||
func getDbConfig() *dbConfig {
|
||||
loadEnv()
|
||||
|
||||
dbUrl := os.Getenv("PG_FROM_DB_URL")
|
||||
if dbUrl == "" {
|
||||
log.Fatal("PG_FROM_DB_URL environment variable not set")
|
||||
}
|
||||
|
||||
return &dbConfig{
|
||||
Url: dbUrl,
|
||||
}
|
||||
}
|
||||
|
||||
var Db *dbConfig = getDbConfig()
|
||||
Reference in New Issue
Block a user