Golang — Extract value from interfaces{} without specifying the Struct Type

Luci Bro
1 min readOct 10, 2019

Let say you pass struct as an interface argument to function and you do not have access to the type struct then how to extract the fields values.

Now you are trying to figure out why the heck i need to do this, lol. But there are many cases where you do not have access to the TYPE.

Let’s take an example i am building a go pkg and i want user to specify there own Table Struct but on my pkg i want to access the values of that struct which i do not have access to directly.

--

--