1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 02:50:49 +00:00

execElem.FieldByName as local variable

execElem.FieldByName(fieldType.Name) as local variable
This commit is contained in:
cloudzhou 2018-01-25 17:52:09 +08:00 committed by GitHub
parent f16688817a
commit 6de538b136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,10 +202,10 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
numOfFields := elemVal.NumField()
for i := 0; i < numOfFields; i++ {
fieldType := elemType.Field(i)
if execElem.FieldByName(fieldType.Name).CanSet() {
elemField := execElem.FieldByName(fieldType.Name)
if elemField.CanSet() {
fieldVal := elemVal.Field(i)
execElem.FieldByName(fieldType.Name).Set(fieldVal)
elemField.Set(fieldVal)
}
}