完整代码在这里:https : //pastebin.com/xC1uQVBC
type UDD struct {
A string //content = "John"
B string //content = "Male"
C string //content = "12345678"
D int64 //content = ""
E uint64 //content = ""
Z string //content = "FIrst time user"
}
reflect_UDD := reflect.ValueOf(&UDD).Elem()
typeOf_UDD := reflect_UDD.Type()
for i := 0; i < reflect_UDD.NumField(); i++ {
f := reflect_UDD.Field(i)
if(f.Type()==reflect.TypeOf("string")){
//i would like to f.Type()=="string" directly...
//how is this possible and also for uint64 and int64 etc
}
}
基本上,我想做一些类似的事情
f.Type()=="string"
或者
f.Type()=="uint64"
或者
f.Type()=="int64"
直接代替
米琪卡哇伊
料青山看我应如是
相关分类