I have been trying to use the importer to parse the types defined in a particular package. However, the importer always return an error saying the package is not found. What mistake I am making?
package main
import (
"fmt"
"go/importer"
)
func main() {
pkg, err := importer.Default().Import("github.com/onsi/ginkgo")
if err != nil {
panic(err)
}
fmt.Println(pkg)
}
I tried to read the go importer documentation, but it provides very limited information. I also tried to use the package I am importing here, but it does not help. However, if I import a go standard package, such as “time”, I can currently import the package. Why is that?