1
0
Fork 0

Add update function

This commit is contained in:
Gregory Eremin 2015-08-29 12:59:45 +03:00
parent 224172be57
commit 8bf455246d
1 changed files with 11 additions and 0 deletions

View File

@ -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 {