This is a creation in Article, where the information may have evolved or changed.
1. Reflection goes from interface value to Reflection Object.
Reflection can be worthwhile from the interface to the reflective object
Use to reflect methods:
Reflect. ValueOf (i interface{}) Value
Reflect. TypeOf (i interface{}) Type
2. Reflection goes from Refelction object to interface value.
Reflection can get interface values from reflected objects
Use to reflect methods:
Reflect. New (Typ Type) Value
Reflect. Zero (Typ Type) Value
Func (v Value) type () type
Func (v Value) Interface () (I interface{})
I. (SOMEINTERFACE)
3. To modify a reflection object, the value must is settable.
To modify a reflection object, its value must be modifiable
Finally add a: type and value of mutual conversion and auxiliary methods
Type->value
Reflect. New (Typ Type) Value
Value->type
Func (v Value) type () type
Pointervalue->value
Func Indirect (v value) value
Func (v Value) Elem () value
Type->pointertype
Func Ptrto (t type) type
Pointertype->type
Func (t type) Elem () type
Note: Go's reflection is not powerful enough, it's different directly from the Java, it is created directly through the class package string, namely: its different through the type name directly constructs type or value, you must first create a type variable, and then the type or value variable. But this can be solved by adding a syntactic sugar.