Repository: go
Issue: x/tools/gopls: "package name is %q, want %q" bug in typeCheckBatch.importPackage
Labels: gopls,Tools,gopls/telemetry-wins

```
#!stacks
"bug.Errorf" &&
("importPackage.func1:+14" || "importPackage.func1:+15" || "importPackage.func1:+18")
```

This stack  `5MRL7A`, `_ZM1lw` was [reported by telemetry](https://storage.googleapis.com/prod-telemetry-merged/2023-11-12.json):

[cache.(*typeCheckBatch).importPackage.func1:19]() is 
```
			// debugging issue #60904
			if pkg.Name() != item.Name {
				return bug.Errorf("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904)",
					pkg.Name(), item.Name, id, item.Path)
			}

```

The related issue #63822 appears to have the same root cause: there are duplicate package paths in the export data manifest; see https://github.com/golang/go/issues/63822#issuecomment-2289843179.


This stack `PXUK4g` was [reported by telemetry](https://storage.googleapis.com/prod-telemetry-merged/2024-09-03.json):

`gopls/bug`
[`golang.org/x/tools/gopls/internal/util/bug.report:+35`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/util/bug/bug.go;l=109)
[`golang.org/x/tools/gopls/internal/util/bug.Errorf:+2`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/util/bug/bug.go;l=61)
[`golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage.func1:+14`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/check.go;l=635)
`golang.org/x/tools/internal/gcimporter.iimportCommon:+124`
`golang.org/x/tools/internal/gcimporter.IImportShallow:+3`
[`golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage:+57`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/check.go;l=671)
[`golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getImportPackage:+56`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/check.go;l=489)
[`golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage.func2:+1`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/check.go;l=540)
`golang.org/x/sync/errgroup.(*Group).Go.func1:+3`
`runtime.goexit:+0`
```
golang.org/x/tools/gopls@v0.16.1 go1.23.0 darwin/arm64 neovim (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.6 linux/amd64 other,vscode (2)
golang.org/x/tools/gopls@v0.16.1 go1.22.0 darwin/arm64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.3 darwin/arm64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.23.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.6 darwin/arm64 vscode (2)
golang.org/x/tools/gopls@v0.16.2 go1.23.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.5 darwin/arm64 neovim (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.5 linux/amd64 vscode (2)
golang.org/x/tools/gopls@v0.16.1 go1.20.8 darwin/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.4 darwin/arm64 other,vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.0 darwin/arm64 neovim,other (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.6 darwin/arm64 other,vscode (1)
golang.org/x/tools/gopls@v0.16.2-pre.1 go1.22.6 darwin/amd64 other (1)
golang.org/x/tools/gopls@v0.16.2 go1.23.0 darwin/arm64 vscode (1)
golang.org/x/tools/gopls@v0.16.2-pre.2 go1.21.7 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.20.7 linux/amd64 vscode (2)
golang.org/x/tools/gopls@v0.16.1 go1.22.0 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.21.7 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.22.5 darwin/arm64 vscode (1)
golang.org/x/tools/gopls@v0.16.1 go1.23.0 darwin/arm64 vscode (6)
```

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.


```
gopls/bug
golang.org/x/tools/gopls/internal/bug.report:35
golang.org/x/tools/gopls/internal/bug.Errorf:2
golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).importPackage.func1:19
golang.org/x/tools/internal/gcimporter.iimportCommon:116
golang.org/x/tools/internal/gcimporter.IImportShallow:3
golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).importPackage:41
golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).getImportPackage:55
golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).awaitPredecessors.func1:1
golang.org/x/sync/errgroup.(*Group).Go.func1:3
runtime.goexit:0
```
```
golang.org/x/tools/gopls@v0.14.1 go1.21.3 linux/amd64 (2)
golang.org/x/tools/gopls@v0.14.1 go1.19.1 darwin/amd64 (1)
```

Reported using golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

This stack `aiQRfw` was [reported by telemetry](https://storage.googleapis.com/prod-telemetry-merged/2024-02-09.json):

```
gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:35
golang.org/x/tools/gopls/internal/util/bug.Errorf:2
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage.func1:14
golang.org/x/tools/internal/gcimporter.iimportCommon:123
golang.org/x/tools/internal/gcimporter.IImportShallow:3
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage:57
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getImportPackage:55
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func1:1
golang.org/x/sync/errgroup.(*Group).Go.func1:3
runtime.goexit:0
```
```
golang.org/x/tools/gopls@v0.15.0-pre.2 go1.22rc2 linux/amd64 vscode (1)
```

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Dups: ebxaEQ 2vh0nQ

This stack `KVl6Kg` was [reported by telemetry](https://storage.googleapis.com/prod-telemetry-merged/2024-03-05.json):

```
gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Errorf:+2
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage.func1:+14
golang.org/x/tools/internal/gcimporter.iimportCommon:+123
golang.org/x/tools/internal/gcimporter.IImportShallow:+3
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).importPackage:+57
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getImportPackage:+55
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage.func2:+1
golang.org/x/sync/errgroup.(*Group).Go.func1:+3
runtime.goexit:+0
```
```
golang.org/x/tools/gopls@v0.15.0 go1.22.0 darwin/arm64 vscode (1)
```

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.



Dups: Ar_rPw 33irXg PXUK4g ptgmiQ j64HJw FjuvhQ rlqkaQ

Dups without stacks (too numerous): T YioIw
Dups: 8lUnNg nHnxwA C0oOoQ orz9eg LWE90w b-ZEYg lz1QUA JtyMWA JITKgg