Hi,
I am a bit stuck on something that seems to be logical on internet but when I am trying at home impossible to make it works. I created a struct and I am passing it to a method /
user := grinch.User{
Username: “lucas”,
}
p := reflect.ValueOf(&user) // Note: take the address of x.
fmt.Println(“type of p:”, p.Type())
fmt.Println(“settability of p:”, p.CanSet())
v := p.Elem()
fmt.Println(“settability of v:”, v.CanSet())
grinchDb.Where(&user)
When I am checking on my type it’s *grinch.User, everything is alright so far. But when I am checking in the Where method, the value of the type becomes *interface {}, I can of guess why but when I am looking for help on the topic it’s written everywhere that go should remember the original type and so display *grinch.User but it doesn’t
Maybe I am doing something wrong with my code, here is the Where method :
func (g *Grinch) Where(obj interface{}) {
p := reflect.ValueOf(&obj) // Note: take the address of x.
fmt.Println(“type of p:”, p.Type())
fmt.Println(“settability of p:”, p.CanSet())
v := p.Elem()
fmt.Println(“settability of v:”, v.CanSet())
}
Is anyone seeing what I am doing wrong here ?