1
0
Fork 0

Add Manage function (API)

This commit is contained in:
Gregory Eremin 2015-08-29 12:55:34 +03:00
parent 27bb46973f
commit 224172be57
1 changed files with 9 additions and 0 deletions

View File

@ -10,6 +10,15 @@ var (
config interface{}
)
// Manage accepts a pointer to a configuration struct.
func Manage(target interface{}) {
if ok := isStructPtr(target); !ok {
panic("Argument must be a pointer to a struct")
}
config = target
}
func isStructPtr(target interface{}) bool {
if val := reflect.ValueOf(target); val.Kind() == reflect.Ptr {
if val = reflect.Indirect(val); val.Kind() == reflect.Struct {