{"action":"opened","issue":{"url":"https://api.github.com/repos/astaxie/beego/issues/3300","repository_url":"https://api.github.com/repos/astaxie/beego","labels_url":"https://api.github.com/repos/astaxie/beego/issues/3300/labels{/name}","comments_url":"https://api.github.com/repos/astaxie/beego/issues/3300/comments","events_url":"https://api.github.com/repos/astaxie/beego/issues/3300/events","html_url":"https://github.com/astaxie/beego/issues/3300","id":354084206,"node_id":"MDU6SXNzdWUzNTQwODQyMDY=","number":3300,"title":"beego.NSRouter resets the field of controller","user":{"login":"printfcoder","id":20906540,"node_id":"MDQ6VXNlcjIwOTA2NTQw","avatar_url":"https://avatars3.githubusercontent.com/u/20906540?v=4","gravatar_id":"","url":"https://api.github.com/users/printfcoder","html_url":"https://github.com/printfcoder","followers_url":"https://api.github.com/users/printfcoder/followers","following_url":"https://api.github.com/users/printfcoder/following{/other_user}","gists_url":"https://api.github.com/users/printfcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/printfcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/printfcoder/subscriptions","organizations_url":"https://api.github.com/users/printfcoder/orgs","repos_url":"https://api.github.com/users/printfcoder/repos","events_url":"https://api.github.com/users/printfcoder/events{/privacy}","received_events_url":"https://api.github.com/users/printfcoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-26T10:39:20Z","updated_at":"2018-08-26T10:39:20Z","closed_at":null,"author_association":"NONE","body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n1. What version of Go and beego are you using (`bee version`)?\r\n\r\nv1.9.1\r\n\r\n2. What operating system and processor architecture are you using (`go env`)?\r\n\r\ngo1.10.3\r\n\r\n3. What did you do?\r\nI init a custom controller like:\r\n\r\n```golang\r\ntype MyController struct {\r\n     PublicField  anyType \r\n     privateField  anyType \r\n}\r\n\r\nufc := uf.GetC()  // return a inited MyController\r\nns := beego.NSNamespace(\"/account\",\r\n\tbeego.NSRouter(\"/create-new-user-friend\", ufc, \"POST:CreateNewFriend\"),)\r\n```\r\n\r\nI read beego source code(astaxie/beego/router.go): \r\n\r\n```golang\r\nfor i := 0; i < numOfFields; i++ {\r\n    fieldType := elemType.Field(i)\r\n    elemField := execElem.FieldByName(fieldType.Name)\r\n    if elemField.CanSet() {\r\n\tfieldVal := elemVal.Field(i)\r\n        emField.Set(fieldVal)\r\n    }\r\n}\r\n```\r\nfields of controller would be reset but the private fields. I think it is not good. I want make controller keeps it private field anyway. but private(unexported) field can not be set because **elemField.CanSet()** returns **false**\r\n\r\n4. What did you expect to see?\r\n\r\n**beego.NSRouter** holds the controller's unexported field value.\r\n\r\n5. What did you see instead?\r\n\r\n**beego.NSRouter** reset controller's unexported field value to nil."}}
{"actor":{"display_login":"printfcoder"}}