package main import ( "fmt" "reflect" ) func main() { var x int = 42 fmt.Println(reflect.TypeOf(x).Name()) // Output: int }
package main import ( "fmt" "reflect" ) type person struct { name string age int } func main() { p := person{name: "Alice", age: 30} fmt.Println(reflect.TypeOf(p).Name()) // Output: person }Package Library: The reflect package is part of the Go standard library, so there is no need to import any external package to use it.