支持传入的跟结构就是数组

This commit is contained in:
2025-03-23 20:54:35 +08:00
parent 0b609e8e26
commit bc91937116
4 changed files with 83 additions and 10 deletions

View File

@ -7,7 +7,9 @@
// Date : 2025-03-23 14:14
package dynamicstruct
import "reflect"
import (
"reflect"
)
type dynamicStructImpl struct {
structFields []reflect.StructField
@ -16,7 +18,6 @@ type dynamicStructImpl struct {
// New 创建动态结构体实例
func (ds *dynamicStructImpl) New() any {
// 不要指针,全部解引用
return reflect.New(ds.definition).Interface()
}