From 90eac82f697b95db2cd3430af1d585b2eb0701ba Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Sat, 21 Sep 2013 08:59:37 -0700 Subject: [PATCH] config: Add a default json encoder. --- config/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/config.go b/config/config.go index ed38119..ae33182 100644 --- a/config/config.go +++ b/config/config.go @@ -20,6 +20,12 @@ func DecodeJsonConfig(r io.Reader, v interface{}) error { return d.Decode(v) } +// Simple JSON based configuration encoder. +func EncodeJsonConfig(w io.Writer, v interface{}) error { + e := json.NewEncoder(w) + return e.Encode(v) +} + // Return a configuration file path. If baseName is empty, // then the current executable name without the extension // is used. If postfix is empty then DefaultPostfix is used.