The go tool sets a field to indicate whether a package is part of the standard library:
https://github.com/golang/go/blob/8d478e845c/src/cmd/go/pkg.go#L156
p.Standard = p.Goroot && p.ImportPath != "" && !strings.Contains(p.ImportPath, ".")
goimports uses a different rule:
https://github.com/golang/tools/blob/e21b7325f7/imports/fix.go#L32
if strings.Contains(importPath, ".") {
My feature request is to change the code to behave similar to the go tool:
if strings.Contains(importPath, ".") || !inGoroot(importPath) {
With an additional index of the standard library keyed by import path, I'd expect this to be reasonably fast.
If this is an acceptable idea, I'm happy to write a patch.