| 213 | } |
| 214 | |
| 215 | func databaseURL() string { |
| 216 | dburl := os.Getenv("DATABASE_URL") |
| 217 | if dburl != "" { |
| 218 | return dburl |
| 219 | } |
| 220 | pgUser := os.Getenv("PG_USER") |
| 221 | pgHost := os.Getenv("PG_HOST") |
| 222 | pgPort := os.Getenv("PG_PORT") |
| 223 | pgPass := os.Getenv("PG_PASSWORD") |
| 224 | pgDB := os.Getenv("PG_DATABASE") |
| 225 | if pgUser == "" { |
| 226 | pgUser = "postgres" |
| 227 | } |
| 228 | if pgPass == "" { |
| 229 | pgPass = "mysecretpassword" |
| 230 | } |
| 231 | if pgPort == "" { |
| 232 | pgPort = "5432" |
| 233 | } |
| 234 | if pgHost == "" { |
| 235 | pgHost = "127.0.0.1" |
| 236 | } |
| 237 | if pgDB == "" { |
| 238 | pgDB = "dinotest" |
| 239 | } |
| 240 | return fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", pgUser, pgPass, pgHost, pgPort, pgDB) |
| 241 | } |
| 242 | |
| 243 | func run(ctx context.Context) error { |
| 244 | flag.Parse() |