From 224172be5703bf09751834ef6227dd0a5b3c5802 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sat, 29 Aug 2015 12:55:34 +0300 Subject: [PATCH] Add Manage function (API) --- confection.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confection.go b/confection.go index 86cc79a..fc1d803 100644 --- a/confection.go +++ b/confection.go @@ -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 {