In Go, how to verify that the data type of an input from the user matches the data type of the code?

I am new to Go.

Currently, I am creating a menu in Go and I want to verify that the data type of the input from the user matches the data type of the variable defined in the code. Part of my code looks like this so far:

package main
import (
    "fmt"
    "reflect"
)

var option int // The variable is declared outside of the main().

func general_menu() {
    fmt.Println(".......................General Menu..................................")
        fmt.Println()
        fmt.Println("Calculator..........................................................1")
        fmt.Println("Linear algebra package..............................................2")
        fmt.Println("Language change.....................................................9")
        fmt.Println("Exit...............................................................10")
        fmt.Println()
        fmt.Println("Choose an option from the menu.")
        fmt.Println()
        fmt.Scan(&option)
        fmt.Println()
        if (option != 1 && option != 2 && option != 9 && option != 10)||reflect.TypeOf(option)!=int{
            fmt.Println("Wrong option input. Please, try again.")
            fmt.Println()
            general_menu()
        }
}

I know that this doens't work this way, and I know that "int" can not be used as part of an "if" condirion.

I would kindly appreciate any suggestions on the proper way to solve this problem.

Thanks.

Edit: I have added more of my code as kindly suggested by the contributors.

Edit: Based on the answer provided, I have tried to implement a function, but the syntax is still not correct:

func check_integers_are_not_string(x int) bool {
    change := strconv.Itoa(x)
    if change != nil {
        return true
    } else {
        return false
    }
} // This function returns a true boolean value if conversion from int to string was possible, meaning that the entered value is a string.

Solution 1:

One common way to do it is to try to make the conversion and see if it succeeds.

optionInt, err := strconv.Atoi(option) // Assuming option is of type string
if err != nil {
    log.Printf("String '%s' cannot be converted to type int: %v", option, err)
    os.Exit(1)
}
log.Printf(`optionInt is %d.`, optionInt)

This is a good approach if you are only interested in conversion to one type. Otherwise things can quickly get more involved, utilizing constructs such as lexers and parsers, but that would warrant more information on what you are trying to accomplish.