Skip to content

Commit 2ad6325

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/lsp/cache: expand ImportPath!=PackagePath comment
Change-Id: I2ea748a6a434bada2a310581538ac5d8dcefa01e Reviewed-on: https://go-review.googlesource.com/c/tools/+/454562 Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Alan Donovan <adonovan@google.com>
1 parent 52c7b88 commit 2ad6325

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

gopls/internal/lsp/cache/load.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,30 @@ func buildMetadata(ctx context.Context, pkg *packages.Package, cfg *packages.Con
552552
// (Beware that, for historical reasons, go list uses
553553
// the JSON field "ImportPath" for the package's
554554
// path--effectively the linker symbol prefix.)
555+
//
556+
// The example above is slightly special to go list
557+
// because it's in the std module. Otherwise,
558+
// vendored modules are simply modules whose directory
559+
// is vendor/ instead of GOMODCACHE, and the
560+
// import path equals the package path.
561+
//
562+
// But in GOPATH (non-module) mode, it's possible for
563+
// package vendoring to cause a non-identity ImportMap,
564+
// as in this example:
565+
//
566+
// $ cd $HOME/src
567+
// $ find . -type f
568+
// ./b/b.go
569+
// ./vendor/example.com/a/a.go
570+
// $ cat ./b/b.go
571+
// package b
572+
// import _ "example.com/a"
573+
// $ cat ./vendor/example.com/a/a.go
574+
// package a
575+
// $ GOPATH=$HOME GO111MODULE=off go list -json ./b | grep -A2 ImportMap
576+
// "ImportMap": {
577+
// "example.com/a": "vendor/example.com/a"
578+
// },
555579

556580
// Don't remember any imports with significant errors.
557581
//

0 commit comments

Comments
 (0)