Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: can't use gopls snippet in devcontainer(variable.Print! -> fmt.Printf("variable: %v\n", variable)) #61292

Closed
git-shochann opened this issue Jul 11, 2023 · 4 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@git-shochann
Copy link

git-shochann commented Jul 11, 2023

What version of Go are you using (go version)?

docker container created by devcontainer
go version go1.20.4 linux/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-buildvcs=false"
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="http://sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/go/src/myProject/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1012517003=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Snippet functions provided by gopls
variables.Print!and do it locally,
fmt.Printf("variable: %v\n", variable) will be displayed.

However, in containers created with devcontainer,
that functionality is not available.

Both vscode-go extension(.devcontainer.json) and gopls are installed(dockerFile)

Why is this?

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 11, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 11, 2023
@findleyr
Copy link
Contributor

Hi, is gopls otherwise working (i.e. normal completion works?).

Are you setting "experimentalPostfixCompletions"?

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 13, 2023
@git-shochann
Copy link
Author

git-shochann commented Jul 14, 2023

@findleyr Thanks for your reply

That was correct, I added that to devcontainer.json and it worked with containers.

But why do I need to explicitly add the following to devcontainer.json when gopls is installed in the container?

   "gopls": {
      "experimentalPostfixCompletions": true.
   }

Looking at the local setting.json, I see no problem even though there is no mention of "experimentalPostfixCompletions": true.

What is the difference?

The local version of gopls and the version of gopls installed in the container are the same.

golang.org/x/tools/gopls v0.12.4
golang.org/x/tools/gopls@v0.12.4 h1:nce5etAamR46d9oNGxop1aRK5rDQ0NqcY/SHIcyfEKY=

@hyangah
Copy link
Contributor

hyangah commented Jul 25, 2023

@git-shochann Can you capture the gopls trace? For vscode, see https://github.com/golang/vscode-go/wiki/troubleshooting#collect-gopls-information We need the trace from the gopls start to the point it exchanges configuration messages. You can redact confidential file names, etc, but leave the initialization and configuration related messages untouched if possible.

experimentalPostfixCompletions settings should be true by default. In vscode-go, it corresponds to "gopls": { "ui.completion.experimentalPostfixCompletions": true }. But maybe configuration is not propagated correctly in devcontainer.

@git-shochann
Copy link
Author

Sorry. My mistake. It was turned off in .code-workspace file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants