Add update function
This commit is contained in:
parent
224172be57
commit
8bf455246d
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue