From 8bf455246d0b228c9ed040e08476b34ae883276e Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sat, 29 Aug 2015 12:59:45 +0300 Subject: [PATCH] Add update function --- confection.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/confection.go b/confection.go index fc1d803..3d40025 100644 --- a/confection.go +++ b/confection.go @@ -2,6 +2,7 @@ package confection2 import ( "encoding/json" + "log" "reflect" ) @@ -19,6 +20,16 @@ func Manage(target interface{}) { config = target } +func update(body []byte) { + dupe := duplicate(config) + if err := unmarshal(body, dupe); err != nil { + log.Println("Failed to update config") + return + } + + config = dupe +} + func isStructPtr(target interface{}) bool { if val := reflect.ValueOf(target); val.Kind() == reflect.Ptr { if val = reflect.Indirect(val); val.Kind() == reflect.Struct {