I tried a function like this:
func getStuctName(aStruct interface{}) string {
typeof := reflect.TypeOf(aStruct)
if typeof.Kind() == reflect.Ptr {
typeof = typeof.Elem()
}
return typeof.Name()
}
And I have a blank result: ""
When I call my function with a pointer of a struct.
func callerFunction(aStruct interface{}) {
fmt.Println(getStructName(&aStruct))
}
Aucun commentaire:
Enregistrer un commentaire