Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gconv.Struct方法转换问题 #2371

Closed
zhoxife3ng opened this issue Dec 21, 2022 · 2 comments
Closed

gconv.Struct方法转换问题 #2371

zhoxife3ng opened this issue Dec 21, 2022 · 2 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version.

Comments

@zhoxife3ng
Copy link

1. What version of Go and system type/arch are you using?

go version go1.17.3 darwin/arm64

2. What version of GoFrame are you using?

使用了两个版本测试,结果不一样
1、1.16.7
2、2.2.2

3. Can this issue be re-produced with the latest release?

4. What did you do?

func main() {
   var (
      testStruct = struct {
         Time time.Time `json:"time"`
      }{}
      jsonMap = map[string]interface{}{"time": "2022-12-15 16:11:34"}
   )
 
   if err := gconv.Struct(jsonMap, &testStruct); err != nil {
      fmt.Println("gconv.Struct jsonMap失败:", err)
   } else {
      fmt.Println("gconv.Struct jsonMap成功")
   }
 
   // 输出 使用gf v1.16.7结果
   //gconv.Struct jsonMap成功

   // 输出 使用gf v2.2.2结果
   //gconv.Struct jsonMap失败: parsing time "2022-12-15 16:11:34" as "2006-01-02T15:04:05Z07:00": cannot parse " 16:11:34" as "T"
}

5. What did you expect to see?

从旧版升级到gf2之后,希望gconv.Struct方法是向下兼容的,尤其是对time.Time的转换

https:/gogf/gf/blob/master/util/gconv/gconv_struct.go#L371
Common interface check失败后能否再次尝试使用Default converting进行转换

6. What did you see instead?

@gqcn
Copy link
Member

gqcn commented Feb 6, 2023

@zhoxife3ng 感谢反馈。

@gqcn gqcn added the bug It is confirmed a bug, but don't worry, we'll handle it. label Feb 6, 2023
gqcn added a commit that referenced this issue Feb 8, 2023
@gqcn
Copy link
Member

gqcn commented Feb 8, 2023

#2429

@gqcn gqcn added the done This issue is done, which may be release in next version. label Feb 8, 2023
@gqcn gqcn closed this as completed Feb 8, 2023
gqcn added a commit that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version.
Projects
None yet
Development

No branches or pull requests

2 participants