Using reflection, we can get the type name, storage size, and a function of that type (for example, uint64, user-defined structure, etc.). Even we can modify some fields of this type. How does golang implement reflection? I suggest the following methods:
Each golang type, including the user type, itself has information about the type name, field name, and function name. Golang reflection simply reads this information or calls a function.
Through some mechanism, Golang can get the type name, storage size, etc. And the type itself does not have this information.
I read the golang reflection code approximately. I guessed that the golang used the second way. Who can describe a specific reflection tool? Or recommend me some documents? Reading all the code is difficult for me.
source share