gf
gf copied to clipboard
util/gconv: when Scan **Struct to **Struct, if dstValue is nil, will return reflect: reflect.Value.Set using unaddressable value
Go version
1.25.4
GoFrame version
2.9.4
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
package gconv
import (
"fmt"
"testing"
)
type User struct {
Id int64
}
func TestScan(t *testing.T) {
var user *User
cacheValue := &User{Id: 1}
err := Scan(&cacheValue, &user)
if err != nil {
t.Error(err)
}
fmt.Printf("user:%+v\n", user)
}
What did you see happen?
=== RUN TestScan
gconv_scan_test.go:17: reflect: reflect.Value.Set using unaddressable value
user:
What did you expect to see?
when in goframe version 2.6.3, it is ok.
The right thing to do is this
gconv.Scan(cacheValue, &user)
The right thing to do is this
gconv.Scan(cacheValue, &user)
It can run normally in versions earlier than 2.6.3