github.com/niubaoshu/goutils@v0.0.0-20180828035119-e8e576f66c2b/reflect/reflect.go (about) 1 package reflect 2 3 import ( 4 "reflect" 5 "strconv" 6 ) 7 8 func GetInAndOut(rt reflect.Type) (in reflect.Type, out reflect.Type) { 9 ni, no := rt.NumIn(), rt.NumOut() 10 inArg, outArg := make([]reflect.StructField, ni), make([]reflect.StructField, no) 11 for i := 0; i < ni; i++ { 12 inArg[i].Type = rt.In(i) 13 inArg[i].Name = "In" + strconv.Itoa(i) 14 } 15 in = reflect.StructOf(inArg) 16 17 for i := 0; i < no; i++ { 18 outArg[i].Type = rt.Out(i) 19 outArg[i].Name = "Out" + strconv.Itoa(i) 20 } 21 out = reflect.StructOf(outArg) 22 return 23 } 24 25 func assignment(a, b interface{}) { 26 27 }