From 3ad72640bbf41daea3da24f67507192d26dab4c5 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Fri, 9 Nov 2018 16:15:51 +0100 Subject: [PATCH] upd(internal): - don't provide fault db connection setting - prefix is optional, check if we have it --- internal/config/database.go | 7 +++++-- internal/config/http.go | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/config/database.go b/internal/config/database.go index 1afc32d1e..e816ba772 100644 --- a/internal/config/database.go +++ b/internal/config/database.go @@ -30,11 +30,14 @@ func (*Database) Init(prefix ...string) *Database { } p := func(s string) string { - return prefix[0] + "-" + s + if len(prefix) > 0 { + return prefix[0] + "-" + s + } + return s } db = new(Database) - flag.StringVar(&db.DSN, p("db-dsn"), "crust:crust@tcp(db1:3306)/crust?collation=utf8mb4_general_ci", "DSN for database connection") + flag.StringVar(&db.DSN, p("db-dsn"), "", "DSN for database connection (e.g. user:pass@tcp(db1:3306)/dbname?collation=utf8mb4_general_ci)") flag.StringVar(&db.Profiler, p("db-profiler"), "", "Profiler for DB queries (none, stdout)") return db } diff --git a/internal/config/http.go b/internal/config/http.go index 2369fb91f..04063f1b7 100644 --- a/internal/config/http.go +++ b/internal/config/http.go @@ -38,7 +38,10 @@ func (*HTTP) Init(prefix ...string) *HTTP { } p := func(s string) string { - return prefix[0] + "-" + s + if len(prefix) > 0 { + return prefix[0] + "-" + s + } + return s } http = new(HTTP)