gogf / gf

GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
https://goframe.org
MIT License
11.8k stars 1.61k forks source link

[v2.7.0] gconv.Struct is not compatible with previous versions #3534

Closed qinyuguang closed 6 months ago

qinyuguang commented 7 months ago

Example

package main

import (
    "github.com/gogf/gf/v2/frame/g"
    "github.com/gogf/gf/v2/util/gconv"
    "github.com/gogf/gf/v2/util/gutil"
)

type Something struct {
    Value string `json:"value2"`
}

func main() {
    m1 := g.Map{
        "Value2": "hello",
    }

    var s1 *Something
    _ = gconv.Struct(m1, &s1)

    gutil.DumpWithType(s1)
}

Result

gf2.6.4

*main.Something(1) {
    Value: string(5) "hello",
}

gf2.7.0

*main.Something(1) {
    Value: string(5) "",
}
wln32 commented 7 months ago

@qinyuguang Version 2.7.0 updates the field matching rules, please refer to the documentation for details https://goframe.org/pages/viewpage.action?pageId=1114345 1