mirror of https://github.com/golang/go.git
Editor modes that invoke the goimports command on temporary copies
of actual source files will need to invoke goimports -srcdir now to say
where the real source directory is. Otherwise goimports will not consider
vendored or internal packages when looking for new imports.
In lieu of a test for cmd/goimports (because it has no tests),
a command transcript:
$ cd /tmp
$ cat x.go
package p
var _ = hpack.HuffmanDecode
$
$ GOPATH= goimports < x.go
package p
var _ = hpack.HuffmanDecode
$ GOPATH= goimports x.go
package p
var _ = hpack.HuffmanDecode
$
But with the new flag:
$ GOPATH= goimports -srcdir $GOROOT/src/math < x.go
package p
import "golang.org/x/net/http2/hpack"
var _ = hpack.HuffmanDecode
$ GOPATH= goimports -srcdir $GOROOT/src/math x.go
package p
import "golang.org/x/net/http2/hpack"
var _ = hpack.HuffmanDecode
$
The tests in this CL and the above transcript assume that
$GOROOT/src/vendor/golang.org/x/net/http2/hpack exists.
It did in
|
||
|---|---|---|
| .. | ||
| benchcmp | ||
| bundle | ||
| callgraph | ||
| cover | ||
| digraph | ||
| eg | ||
| fiximports | ||
| godex | ||
| godoc | ||
| goimports | ||
| gomvpkg | ||
| gorename | ||
| gotype | ||
| guru | ||
| html2article | ||
| oracle | ||
| present | ||
| ssadump | ||
| stress | ||
| stringer | ||
| tip | ||
| vet | ||