patch reflect: Append/Index; Int fix

This commit is contained in:
xushiwei
2024-06-21 03:29:24 +08:00
parent 0e6f5d154e
commit f26311c60e
9 changed files with 972 additions and 132 deletions

13
_demo/reflect/reflect.go Normal file
View File

@@ -0,0 +1,13 @@
package main
import "reflect"
func main() {
tyIntSlice := reflect.SliceOf(reflect.TypeOf(0))
v := reflect.Zero(tyIntSlice)
v = reflect.Append(v, reflect.ValueOf(1), reflect.ValueOf(2), reflect.ValueOf(3))
for i, n := 0, v.Len(); i < n; i++ {
item := v.Index(i)
println(item.Int())
}
}