I am trying to list all imported types from a given import path at runtime. Sample code:
package main
import (
"fmt"
"go/importer"
)
func main() {
pkg, err := importer.Default().Import("github.com/aler9/goroslib/pkg/msgs/std_msgs")
if err != nil {
fmt.Println("error:", err)
return
}
for _, declName := range pkg.Scope().Names() {
fmt.Println(declName)
}
}
This results in error:
error: can't find import: "github.com/aler9/goroslib/pkg/msgs/std_msgs"
It is possbile to achieve what I want with Golang?
Note:
I am aware of the post: How to use go importer
By using pkg, err := importer.Default().Import("github.com/aler9/goroslib") the binary returns a few types but they are not what I want.