more boilerplate and dev environment
This commit is contained in:
+8
-2
@@ -20,8 +20,14 @@ func InitDB() (*sql.DB, error) {
|
||||
password = "secret"
|
||||
}
|
||||
|
||||
// Build the DSN. The host "db" matches the service name in docker-compose.yml.
|
||||
dsn := fmt.Sprintf("oworganizer:%s@tcp(db:3306)/?parseTime=true", password)
|
||||
host := os.Getenv("DB_HOST")
|
||||
if host == "" {
|
||||
// Default to the Docker Compose service name.
|
||||
host = "db"
|
||||
}
|
||||
|
||||
// Build the DSN. The default host "db" matches the service name in docker-compose.yml.
|
||||
dsn := fmt.Sprintf("oworganizer:%s@tcp(%s:3306)/?parseTime=true", password, host)
|
||||
|
||||
db, err := sql.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user