fix(net/ghttp): 修复当上传文件参数的类型为string时panic的问题
Fixes #4193
@hailaz @gqcn 是否需要给ghttp定义一个单独的converter?
@hailaz @gqcn 是否需要给ghttp定义一个单独的converter?
我不知道,我改这个的时候绕了很久,也不知道这样解决是否合理。 本来想在converter里面处理的,但是类型一引用就导致包循环引用了。
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
@hailaz @gqcn Do you need to define a separate converter for ghttp?
I don’t know. I went around for a long time when I changed this, and I don’t know if this solution is reasonable. I originally wanted to handle it in converter, but once a type is referenced, it causes a package to be recycled.
@hailaz @gqcn 是否需要给ghttp定义一个单独的converter?
我不知道,我改这个的时候绕了很久,也不知道这样解决是否合理。 本来想在converter里面处理的,但是类型一引用就导致包循环引用了。
可以像orm那样,给ghttp包单独定义一个converter,不和gconv中的共享,可以把ghttp包中目前所有用到gconv的地方,都替换为ghttp中自定义的converter,issue #2913 中提到,目前ghttp对于参数转换错误的,直接返回了默认值,没有返回错误
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
@hailaz @gqcn Do you need to define a separate converter for ghttp?
I don’t know, I went around for a long time when I changed this, and I don’t know if this solution is reasonable. I originally wanted to handle it in converter, but once a type is referenced, it causes a package to be recycled.
Like orm, you can define a converter for the ghttp package separately, which is not shared with gconv. You can replace all the places in the ghttp package that are currently used with ghttp with the custom converter in ghttp. It is mentioned in issue #2913 that currently, for parameter conversion errors, ghttp directly returns the default value and does not return an error.
既然选择了注册自定义类型这个方式,为什么不把框架中非标准库的类型解耦出来,使用注册的方式在自定义类型所在的包进行注册,也能同时简化gconv中的逻辑。
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Since you have chosen to register a custom type, why not decouple the non-standard library types in the framework and register in the package where the custom type is located by registering, which can also simplify the logic in gconv.
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Since you have chosen to register a custom type, why not decouple the non-standard library types in the framework and register in the package where the custom type is located by registering, which can also simplify the logic in gconv.
这个自动翻译真的很影响交流,现在翻译插件已经很常见了,真的没有必要自动翻译。有心人根本不会因为没有翻译而不交流
@wln32 @hailaz 我没有在这个pr上修改,我新提了一个pr来修复这个问题,大家看看呢 https://github.com/gogf/gf/pull/4226 。其中比较重要一个改动是,如果是结构体转换,那么这里直接返回转换错误,不再进一步执行反射转换: