add support to update permissions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -102,3 +102,20 @@ func AppendIfNotExists[T Identifiable](slice []T, element T) []T {
|
||||
// Element with the same Id does not exist, append the new element
|
||||
return append(slice, element)
|
||||
}
|
||||
|
||||
// UpdateStruct updates the values in the destination struct with values from the source struct
|
||||
func UpdateStruct(dest interface{}, src interface{}) {
|
||||
destValue := reflect.ValueOf(dest).Elem()
|
||||
srcValue := reflect.ValueOf(src).Elem()
|
||||
|
||||
destType := destValue.Type()
|
||||
|
||||
for i := 0; i < srcValue.NumField(); i++ {
|
||||
srcField := srcValue.Field(i)
|
||||
|
||||
destField := destValue.FieldByName(destType.Field(i).Name)
|
||||
if destField.IsValid() && destField.Type() == srcField.Type() && destField.CanSet() {
|
||||
destField.Set(srcField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user