package main import ( "fmt" "go/types" ) func main() { var x interface{} = 42 fmt.Println(types.Underlying(x)) }
package main import ( "fmt" "go/types" ) func main() { type myInt int var x myInt = 42 fmt.Println(types.Underlying(x)) }This program creates a new custom type `myInt` that is an alias for the `int` type. It then creates a variable of this type and calls the `Underlying` function on it, which returns `int` as the underlying type. In summary, the `Underlying` type in the `go/types` package is used to access the base type of a given Go type. It is useful for type-checking and introspection of Go code.