Find Out Golang Variable Type

How to find out the variable type of the variable you are using in Go/Golang? I had this issue when I was using Bolt DB package and tried to share the connection by passing the db variable around.

To return it, your function needs to declare the variable type it is returning. To pass it into a function, the function needs to declare the variable type being passed in. To find out the variable type, I used the reflect package.

package mainimport (
"fmt"
"reflect"
)
func main() {
s := "golang"
i…