Is there a way in Go to list all the standard/built-in packages (i.e., the packages which come installed with a Go installation)?
I have a list of packages and
Use the go list std
command to list the standard packages. The special import path std
expands to all packages in the standard Go library (doc).
Exec that command to get the list in a Go program:
cmd := exec.Command("go", "list", "std")
p, err := cmd.Output()
if err != nil {
// handle error
}
stdPkgs = strings.Fields(string(p))