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/cmd/gopls: completions aren't provided for the "syscall/js" package #32892

Closed
frou opened this issue Jul 2, 2019 · 3 comments
Closed

x/tools/cmd/gopls: completions aren't provided for the "syscall/js" package #32892

frou opened this issue Jul 2, 2019 · 3 comments

Comments

@frou
Copy link
Contributor

@frou frou commented Jul 2, 2019

Should completions for the "syscall/js" package be working? i.e. after importing it and typing js.

As you know, js is a kind of pseudo GOOS, and is not going to be equal to the OS the editor and gopls are running on (in my case, darwin). Regardless, we still need completions for this part of the standard library!

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

$ go version
go version go1.12.6 darwin/amd64

$ gopls version
version v0.1.1-cmd.gopls, built in $GOPATH mode

Sublime Text + LSP package

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/holmdunc/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/holmdunc/workspace/programming/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/zn/dlsz3cn50kv_93ct2hbfhf6h0000gn/T/go-build564583090=/tmp/go-build -gno-record-gcc-switches -fno-common"
@gopherbot gopherbot added this to the Unreleased milestone Jul 2, 2019
@gopherbot gopherbot added the gopls label Jul 2, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 2, 2019

This is really an effect of #29202. You can work around this for now by configuring buildFlags in your gopls settings (I am not sure how to do this in Sublime, but in VSCode, it would look like "gopls": {"buildFlags": [...]}). See https://github.com/golang/tools/blob/f80f67146e584e84e6c179fdb72a38f367331d6e/internal/lsp/general.go#L181.

Closing as duplicate of #29202.

@stamblerre stamblerre closed this Jul 2, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: Completions aren't provided for the "syscall/js" package x/tools/cmd/gopls: completions aren't provided for the "syscall/js" package Jul 2, 2019
@frou
Copy link
Contributor Author

@frou frou commented Jul 2, 2019

@stamblerre Thanks. It seems that the way Sublime's LSP sends settings is not supported by gopls yet: server: method "DidChangeConfiguration" not yet implemented

However, I did get the completion to work using this (LSP.sublime-settings file):

{
    "clients": {
        "gopls": {
            "enabled": true,
            // "settings": {
            //     "gopls": {
            //         "buildFlags": ["-tags", "js"]
            //   }
            // },
            "env": {
                "GOOS": "js",
                "GOARCH": "wasm",
            }
        }
    }
}

But for anyone else reading... as mentioned in the linked issue, it's not wise to have these kind of tweaks set globally.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 2, 2019

Glad to hear you got it working! The DidChangeConfiguration error just means that you will need to restart Sublime after modifying configurations, but otherwise, the buildFlags should work.

@golang golang locked and limited conversation to collaborators Jul 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.