如何将reflect.Value转换为其类型?
type Cat struct { Age int } cat := reflect.ValueOf(obj) fmt.Println(cat.Type()) // Cat fmt.Println(Cat(cat).Age) // doesn't compile fmt.Println((cat.(Cat)).Age) // same
谢谢!
reflection go
go ×1
reflection ×1