feat: Append 方法支持 R 接口包装的指针类型

增强 setValue 函数,支持将 R 接口包装的指针值追加到非指针类型的切片中。当源值是指针但目标不是指针时,自动解引用后再赋值,使得 New(&item) 可以追加到 []Item 类型的切片。同时统一使用 Raw() 方法替代 Value() 方法名。
This commit is contained in:
2025-12-08 17:24:45 +08:00
parent f5f261e541
commit bacec92841
4 changed files with 264 additions and 6 deletions

View File

@@ -802,12 +802,12 @@ func TestAny(t *testing.T) {
}
}
// TestValue 测试 Value 方法
func TestValue(t *testing.T) {
// TestRaw 测试 Value 方法
func TestRaw(t *testing.T) {
p := Person{Name: "Henry"}
rfx := New(&p)
val := rfx.Value()
val := rfx.Raw()
if !val.IsValid() {
t.Error("Value() returned invalid value")
}