From 33389b0719c78de5fc5694a173f951b3666c183b Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 28 Dec 2018 18:57:07 -0500 Subject: Read database address from command line args --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 998791a..a8afe72 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "html/template" "log" "net/http" + "os" "strconv" "time" ) @@ -67,7 +68,10 @@ func (app *App) loginHandler(w http.ResponseWriter, r *http.Request) { func main() { //log.SetFlags(log.LstdFlags) - store := NewPgStore() + if len(os.Args) == 1 { + log.Fatalf("Usage: %s \n", os.Args[0]) + } + store := NewPgStore(os.Args[1]) template := template.Must(template.New("").ParseGlob("templates/*.tmpl")) app := &App{store, template} http.HandleFunc("/validate", app.validateHandler) -- cgit v1.2.3-70-g09d2