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

Merge pull request #2978 from BorisBorshevsky/fix_reflection_bug

fix bug #2972
This commit is contained in:
astaxie 2017-12-18 19:18:59 +08:00 committed by GitHub
commit f16688817a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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