Description
What version of Go are you using (go version
)?
go version go1.13.5 darwin/amd64
Does this issue reproduce with the latest release?
The version of gopls is fairly recent, as of this writing:
golang.org/x/tools/gopls 0.2.2
golang.org/x/tools/[email protected] h1:ujGisyytgY1VGcmd66wIJ9+wVAfmodXj6daHM43HRXk=
What operating system and processor architecture are you using (go env
)?
go env
Output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/seh/Library/Caches/go-build" GOENV="/Users/seh/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/seh/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.13.5/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.13.5/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/seh/src/uber/kubernetes/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d5/r0rch5j95zjcjmh12gzb7lfc0000gn/T/go-build161365972=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Using an editor that inserts balanced delimiters—such as a closing parenthesis character after typing an opening parenthesis character—try to complete the function literal parameter type config
at the cursor position, denoted by <>
here:
type config struct {
}
type Option func(*config) error
func WithSomeOption(n int) Option {
return func(c *co<>)
}
What did you expect to see?
gopls would respond to the editor's request for completion there, and supply the identifier config
as a good option.
What did you see instead?
gopls stalls for a long while, but never produces any suggestions for completion.
If I delete the closing parenthesis after the co
above, like this, gopls does offer completion suggestions:
func WithSomeOption(n int) Option {
return func(c *co<>
}
Similarly, if I round out more of the function literal, and move the cursor back after "co," gopls will offer completion suggestions:
func WithSomeOption(n int) Option {
return func(c *co<>) error {
}
}
I can see that in various states of being incomplete, this is not yet valid code. However, given the propensity for editors to help us with balanced delimiter insertion, it would be nice to accommodate completion in this situation.