gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/schemax/reflect_test.go (about) 1 package schemax 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 type Enum1 int 9 10 type Class1 struct { 11 Int int 12 String string 13 Int8 int8 14 Any interface{} 15 Int8_2 int8 16 Map map[string]interface{} 17 } 18 19 type Sub struct { 20 } 21 22 const ( 23 Enum1_A Enum1 = iota 24 Enum1_B 25 Enum1_C 26 ) 27 28 type ClassAny struct { 29 Any interface{} 30 } 31 32 func TestName(t *testing.T) { 33 c := &ClassAny{} 34 ParseClass(reflect.TypeOf(c)) 35 } 36 37 //func TestUnsave(t *testing.T) { 38 // c := &Class1{Int: 64, Int8: 8, Int8_2: 8, String: "abc"} 39 // c.Map = map[string]interface{}{ 40 // "a": 1, 41 // } 42 // Set.Create(reflect.TypeOf(c)) 43 // 44 // decl := Set.GetByStruct(c).(*ClassDecl) 45 // for _, val := range decl.Fields { 46 // fmt.Println(val.Name, val.Unsafe.Offset, decl.UnsafeGetByField(unsafe.Pointer(c), val.Name)) 47 // } 48 // 49 //} 50 51 func TestParseClass(t *testing.T) { 52 53 }