From f64eb89ceea470cb14aab73f86fc32a6f1320b8a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 9 Sep 2020 14:17:27 +0200 Subject: [PATCH] Add -config flag --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index cd5438e..f789063 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "log" "net" @@ -8,8 +9,13 @@ import ( "strings" ) +var configPath = "config" + func main() { - cfg, err := Load("config") + flag.StringVar(&configPath, "config", configPath, "path to configuration file") + flag.Parse() + + cfg, err := Load(configPath) if err != nil { log.Fatalf("failed to load config file: %v", err) }