The value returned by reflect.TypeOf is not computed during compile time but during run time. The code for package reflect is generated by the compiler during compile time but this is not interesting to understand reflection at all as it is the same code generation like for lets say net/http.
The source code for package reflect is open source, just have a look. Note that https://golang.org/pkg/reflect/#TypeOf links directly to the source code. Understanding of reflection does not happen by studing the compiler and not the implementation of package reflect but by reading the appropriate blog post on blog.golang.org. V. On Friday, 14 August 2020 04:44:57 UTC+2, xie cui wrote: > > > the return of reflect.TypeOf should be generate by compile, i am trying to > understand it, so i need to know where is code generate it in compiler. i > need to know compiler parts. and i am curious about what is do in user code > also. please tell me about it. i will be appriciated. > On Thursday, August 13, 2020 at 10:47:28 PM UTC+8 Jan Mercl wrote: > >> On Thu, Aug 13, 2020 at 3:53 PM xie cui <cuiw...@gmail.com> wrote: >> >> > ..., i know this type struct in generate by compiler, and i need to >> know where is this code, and how to generate the struct fields and methods? >> >> To avoid the possibility of the XY problem, can you please tell more >> about the goal of "generating struct fields and methods" and what >> exactly is meant by that? Some things can be done by the compiler, >> some in user code and the two feature sets are definitely not the >> same. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/743b4bc9-5296-4891-afb7-bda53fdd915ao%40googlegroups.com.