type Person struct { name string age int } func main() { p := Person{"John", 28} fmt.Println(reflect.TypeOf(p).PkgPath()) // output: main }
package main import ( "fmt" "reflect" "time" ) func main() { d := time.Now() fmt.Println(reflect.TypeOf(d).PkgPath()) // output: time }In this example, we imported the 'time' package and used the `time.Now()` method to get the current time. We then used the `reflect.TypeOf(d).PkgPath()` method to get the package path of the 'Time' type. Since the 'Time' type was defined in the 'time' package, the output is 'time'.