From 6de538b136619510fb3104a8652d3a26590bbef0 Mon Sep 17 00:00:00 2001 From: cloudzhou Date: Thu, 25 Jan 2018 17:52:09 +0800 Subject: [PATCH] execElem.FieldByName as local variable execElem.FieldByName(fieldType.Name) as local variable --- router.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/router.go b/router.go index 11cb4aa8..c6b08e24 100644 --- a/router.go +++ b/router.go @@ -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) } }