In javascript we have typeof operator returns a string indicating the type of the variable. In golang we can write an equivalent function to achieve similar situation by using reflect package.

In the given example we can see the type of the variable as string as like we do in javascript with typeof operator.

But ideally in go we would do things differently.

How we should check the type

Let's see how we can check if a value is a integer or not

reflect.TypeOf(123).Kind() == reflect.Int // true