Skip to content
Snippets Groups Projects
Commit 507791b3 authored by Simon Lindblad's avatar Simon Lindblad
Browse files

Refactor database configuration

parent 74ce58e0
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,11 @@ import (
"strings"
)
const (
postgresUser = "simon"
postgresHost = "localhost"
)
type Task struct {
Id int
Name string
......@@ -145,8 +150,7 @@ func (db *Database) taskHandler(w http.ResponseWriter, r *http.Request) {
}
func ConnectDb() *sql.DB {
// TODO: Refactor the database config
db, err := sql.Open("postgres", "postgres://simon@localhost/todo?sslmode=disable")
db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s@%s/todo?sslmode=disable", postgresUser, postgresHost))
if err != nil {
log.Fatal(err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment