Add Manage function (API)
This commit is contained in:
parent
27bb46973f
commit
224172be57
|
@ -10,6 +10,15 @@ var (
|
||||||
config interface{}
|
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 {
|
func isStructPtr(target interface{}) bool {
|
||||||
if val := reflect.ValueOf(target); val.Kind() == reflect.Ptr {
|
if val := reflect.ValueOf(target); val.Kind() == reflect.Ptr {
|
||||||
if val = reflect.Indirect(val); val.Kind() == reflect.Struct {
|
if val = reflect.Indirect(val); val.Kind() == reflect.Struct {
|
||||||
|
|
Loading…
Reference in New Issue