Top "Go-reflect" questions

Questions about the Go "reflect" package that implements run-time reflection, allowing a program to manipulate objects with arbitrary types.

How to find the type of an object in Go?

How do I find the type of an object in Go? In Python, I just use typeof to fetch the …

go go-reflect
Iterate through the fields of a struct in Go

Basically, the only way (that I know of) to iterate through the values of the fields of a struct is …

go go-reflect
How to compare if two structs, slices or maps are equal?

I want to check if two structs, slices and maps are equal. But I'm running into problems with the following …

go go-reflect
Checking the equality of two slices

How can I check if two slices are equal?

go go-reflect
Type converting slices of interfaces

I'm curious why Go does't implicitly convert []T to []interface{} when it will implicitly convert T to interface{}. Is there …

go go-reflect go-interface
Using reflect, how do you set the value of a struct field?

having a rough time working with struct fields using reflect package. in particular, have not figured out how to set …

go reflection go-reflect
range over interface{} which stores a slice

Given the scenario where you have a function which accepts t interface{}. If it is determined that the t is …

go reflection slice go-reflect
How to get the name of a function in Go?

Given a function, is it possible to get its name? Say: func foo() { } func GetFunctionName(i interface{}) string { // ... } func main() { // …

go reflection go-reflect
Instance new Type (Golang)

Can anyone tell me how to create a new instance of Type from a string? Reflect? There are examples but …

go types instance go-reflect
How do I compare two functions for pointer equality in the latest Go weekly?

In Go, is there any way to compare two non-nil function pointers to test for equality? My standard of equality …

go function-pointers go-reflect