From f465c823f38273d4411819b008513a6b2c69e3f5 Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 11 Jul 2017 19:34:49 +1200 Subject: [PATCH] switch configuration from xml to json --- .gitignore | 1 + cmd/yatwiki-server/main.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dbab7f6..e176252 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ cmd/yatwiki-server/yatwiki-server # Development db files cmd/yatwiki-server/wiki.db +cmd/yatwiki-server/config.json diff --git a/cmd/yatwiki-server/main.go b/cmd/yatwiki-server/main.go index 6911753..577fdc9 100644 --- a/cmd/yatwiki-server/main.go +++ b/cmd/yatwiki-server/main.go @@ -1,7 +1,7 @@ package main import ( - "encoding/xml" + "encoding/json" "flag" "fmt" "io/ioutil" @@ -14,7 +14,7 @@ import ( func main() { bindAddr := flag.String("listen", "127.0.0.1:80", "Bind address") - configPath := flag.String("config", "config.xml", "Configuration file") + configPath := flag.String("config", "config.json", "Configuration file") flag.Parse() opts := yatwiki3.ServerOptions{} @@ -24,7 +24,7 @@ func main() { if err != nil { if os.IsNotExist(err) { opts = *yatwiki3.DefaultOptions() - if cfg, err := xml.MarshalIndent(opts, "", "\t"); err == nil { + if cfg, err := json.MarshalIndent(opts, "", "\t"); err == nil { err := ioutil.WriteFile(*configPath, cfg, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Failed to save default configuration file: %s", err.Error()) @@ -36,7 +36,7 @@ func main() { } } else { fmt.Printf("Loading configuration from '%s'...\n", *configPath) - err = xml.Unmarshal(cfg, &opts) + err = json.Unmarshal(cfg, &opts) if err != nil { fmt.Fprintf(os.Stderr, "Failed to parse configuration file: %s\n", err.Error()) os.Exit(1)