From d8d5050120b4416c7c926fc1ffdb28ff729047d4 Mon Sep 17 00:00:00 2001 From: Matthew Ward Date: Fri, 4 Oct 2013 10:47:26 +0100 Subject: [PATCH] Add command line flag parsing; support for config file path --- server.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 85c97ee..40eb1d5 100644 --- a/server.go +++ b/server.go @@ -2,6 +2,7 @@ package main import ( "log" + "flag" "time" "bytes" "net/http" @@ -13,8 +14,14 @@ import ( ) func main() { + // Parse command line arguments + var ( + config_file = flag.String("config", "", "Path to configuration file") + ) + flag.Parse() + // Load configuration into package variable Config - config_error := gcfg.ReadFileInto(&Config, "config/config.ini") + config_error := gcfg.ReadFileInto(&Config, *config_file) if config_error != nil { log.Fatal("Could not load config file: " + config_error.Error()) }