basic conf for loader

This commit is contained in:
Andreas Schröpfer
2021-02-27 20:09:29 +01:00
parent ac9b441283
commit cc6e58acd9
7 changed files with 375 additions and 0 deletions

20
pkg/set/set.go Normal file
View File

@@ -0,0 +1,20 @@
package set
import (
"errors"
"reflect"
)
func Field(dst interface{}, fieldName string, value interface{}) error {
valDst := reflect.ValueOf(dst).Elem()
dstField := valDst.FieldByName(fieldName)
val := reflect.ValueOf(value)
if dstField.Kind() != val.Kind() {
return errors.New("value-Type does not match to field")
}
dstField.Set(val)
return nil
}