// Package dynamicstruct ... // // Description : dynamicstruct ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2025-03-23 14:14 package dynamicstruct import ( "reflect" ) type dynamicStructImpl struct { structFields []reflect.StructField definition reflect.Type } // New 创建动态结构体实例 func (ds *dynamicStructImpl) New() any { return reflect.New(ds.definition).Interface() } // NewSliceOfStructs 创建动态结构体切片实例 func (ds *dynamicStructImpl) NewSliceOfStructs() any { return reflect.New(reflect.SliceOf(ds.definition)).Interface() } // NewMapOfStructs 创建动态结构体map实例 func (ds *dynamicStructImpl) NewMapOfStructs(key any) any { return reflect.New(reflect.MapOf(reflect.Indirect(reflect.ValueOf(key)).Type(), ds.definition)).Interface() }