type ProtoBufCGIWrap struct { PBRequest proto.Message } // 通过反射来添加baseRequest v := reflect.ValueOf(protoBufCGIWrap.PBRequest) field := v.Elem().FieldByName("BaseRequest") if field.IsValid() { /* var baseRequest BaseRequest base := reflect.New(reflect.TypeOf(baseRequest)) base.Elem().FieldByName("SessionKey").SetBytes([]byte("www.dllhook.com")) base.Elem().FieldByName("DeviceId").SetBytes([]byte("123456789")) base.Elem().FieldByName("DeviceType").SetBytes([]byte("iOS")) */ baseRequest := client.getBaseRequest(Uin,Scene) field.Set(reflect.ValueOf(baseRequest)) fmt.Println(proto.MarshalTextString(protoBufCGIWrap.PBRequest.(proto.Message))) } 膜拜C版~~~
发表评论