package utils import "reflect" func CopyStructMembers(dest, src interface{}) { destValue := reflect.ValueOf(dest).Elem() srcValue := reflect.ValueOf(src).Elem() // typeOfSrc := srcValue.Type() for i := 0; i < destValue.NumField(); i++ { destField := destValue.Field(i) srcField := srcValue.Field(i) if destField.CanSet() && srcField.Type() == destField.Type() { destField.Set(srcField) } } return }