Answer the question
In order to leave comments, you need to log in
How to get value from interface?
Good afternoon.
the answer comes from the database in the form of an interface in which two fields
I want to separately receive only the second field
resp, err := conn.Select("bla bla bla")
fmt.Printf("%T\n", resp.Data)
fmt.Println(resp.Data)
Answer the question
In order to leave comments, you need to log in
You receive not an interface of two fields, but a regular slice (array) of interfaces. Work with it like with any other slice.
fmt.Println(len(resp.Data))
fmt.Println(resp.Data[0])
fmt.Println(resp.Data[1])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question