1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 15:30:55 +00:00

Merge pull request #3039 from cloudzhou/patch-1

execElem.FieldByName as local variable
This commit is contained in:
astaxie 2018-04-20 19:41:07 +08:00 committed by GitHub
commit 507ea757d7
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() numOfFields := elemVal.NumField()
for i := 0; i < numOfFields; i++ { for i := 0; i < numOfFields; i++ {
fieldType := elemType.Field(i) fieldType := elemType.Field(i)
elemField := execElem.FieldByName(fieldType.Name)
if execElem.FieldByName(fieldType.Name).CanSet() { if elemField.CanSet() {
fieldVal := elemVal.Field(i) fieldVal := elemVal.Field(i)
execElem.FieldByName(fieldType.Name).Set(fieldVal) elemField.Set(fieldVal)
} }
} }