But those two lines don't do much, the first line reads the type pointer out of the interface, and the function toType is just a nil check: https://golang.org/src/reflect/type.go?s=38892:38923#L2963
I'm guessing xie cui is looking for where the instances of for example structType: https://golang.org/src/reflect/type.go?s=38892:38923#L435 are created and how the info for the struct fields are filled in. On Friday, August 14, 2020 at 2:52:54 PM UTC+2, Volker Dobler wrote: > > On Friday, 14 August 2020 13:00:19 UTC+2, xie cui wrote: >> >> the return instance of reflect.TypeOf(some object) should be generate by >> compiler, the type info which could be in elf files. i want to known where >> compiler generate it. >> > > Maybe this is the reason for your confusion. > Your assumption that the compiler creates the value returned > by reflect.TypeOf is _plain_ _wrong_. This is _not_ done > during compile time as it cannot be during compile time. > This happens during run time and thus _not_ by the compiler. > > You cannot know where the compiler generates it because > the compiler doesn't generate it. > > The instance which is returned by reflect.TypeOf is generated > by package reflect in the two lines > https://golang.org/src/reflect/type.go#L1367 and 1368. > > V. > -- 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/4df137eb-2a0b-4f51-a55a-7415a08feb32o%40googlegroups.com.