x/tools/gopls: use common package name aliases in unimported completion and goimports #62193
Labels
FeatureRequest
Issues asking for a new feature that does not need a proposal.
gopls/completion
Issues related to auto-completion in gopls.
gopls/imports
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version go1.21.0 windows/amd64
golang.org/x/tools/gopls v0.13.2
vscode version 1.81.1 x64
vscode go extension version 0.39.1
Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: C:\Users\jhendrix\go
GOROOT: C:\Program Files\Go
PATH: C:\Program Files\PowerShell\7;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\PowerShell\7;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Go\bin;C:\Users\jhendrix\AppData\Local\Microsoft\WindowsApps;C:\Users\jhendrix\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\jhendrix\go\bin;C:\Users\jhendrix\AppData\Local\Programs\Fiddler;C:\Program Files\Graphviz\bin;C:\Users\jhendrix.dotnet\tools;C:\Users\jhendrix\AppData\Roaming\npm;C:\Users\jhendrix\go\bin
go env
Workspace Folder (autocompleterepro): c:\git\jhendrixMSFT\autocompleterepro
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jhendrix\AppData\Local\go-build
set GOENV=C:\Users\jhendrix\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\jhendrix\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\jhendrix\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=C:\Users\jhendrix\go\tmp
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=c:\git\jhendrixMSFT\autocompleterepro\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\jhendrix\go\tmp\go-build1620475247=/tmp/go-build -gno-record-gcc-switches
using default Go setting, nothing added/edited
Describe the bug
Using autocomplete to create a stub definition of a
func
within a struct, the aliased package names for the dependent types aren't preserved. Instead, the non-aliased package names are used.Steps to reproduce the behavior:
Clone https://github.com/jhendrixMSFT/autocompleterepro
On line 12, note that the package names for
resp
anderrResp
are incorrect. They should beazfake
but arefake
.To repro, just delete line 12 then recreate it, using the autocomplete prompt to create the stub definition for
Get
.The text was updated successfully, but these errors were encountered: