I am using https://github.com/kataras/iris golang web framework. This is follow up mail from the last question asked here - Fetching Logged in User Info for display - Golang Template
I am finally using code that was mentioned in the previous post like:-
ctx.Values().Get("user")
and the value that user is set or has is "Struct" type:-
// users is struct below
var user users
// details are fetched from DB and assigned to user
// like mentioned here http://go-database-sql.org/retrieving.html
// Now value is set
ctx.Values().Set("user", user);
But after getting the value, When I use in different handler and print:-
user := ctx.Values().Get("user")
fmt.Println(user.ID)
I get the error:-
user.ID undefined (type interface {} is interface with no methods)
I need help in "Type assertion" for the interface. How can i "type assert" above value.
Please let me know, what is the right way to do it. Thanks