Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

No candidates for package syscall/js #56

Closed
eternal-flame-AD opened this issue Sep 11, 2018 · 6 comments
Closed

No candidates for package syscall/js #56

eternal-flame-AD opened this issue Sep 11, 2018 · 6 comments

Comments

@eternal-flame-AD
Copy link

It seemed that gocode failed to provide autocompletion candidates for syscall/js package.

2018/09/11 10:56:31 Got autocompletion request for '/home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go'
2018/09/11 10:56:31 Cursor at: 99
2018/09/11 10:56:31 -------------------------------------------------------
package main

import (
        "fmt"
        "syscall/js"
)

func main() {
        fmt.Println("loaded")
        js.Global()
        j#
}
2018/09/11 10:56:31 -------------------------------------------------------
2018/09/11 10:56:31 Elapsed duration: 1.838556ms
2018/09/11 10:56:31 Offset: 0
2018/09/11 10:56:31 Number of candidates found: 1
2018/09/11 10:56:31 Candidates are:
2018/09/11 10:56:31   package js
2018/09/11 10:56:31 =======================================================
2018/09/11 10:56:32 Got autocompletion request for '/home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go'
2018/09/11 10:56:32 Cursor at: 101
2018/09/11 10:56:32 -------------------------------------------------------
package main

import (
        "fmt"
        "syscall/js"
)

func main() {
        fmt.Println("loaded")
        js.Global()
        js.#
}
2018/09/11 10:56:32 -------------------------------------------------------
2018/09/11 10:56:32 Error parsing input file (outer block):
2018/09/11 10:56:32  /home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go:11:5: expected selector or type assertion, found ';'
2018/09/11 10:56:32 Elapsed duration: 1.581609ms
2018/09/11 10:56:32 Offset: 0
2018/09/11 10:56:32 Number of candidates found: 0
2018/09/11 10:56:32 Candidates are:
2018/09/11 10:56:32 =======================================================
2018/09/11 10:56:32 Got autocompletion request for '/home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go'
2018/09/11 10:56:32 Cursor at: 121
2018/09/11 10:56:32 -------------------------------------------------------
package main
import "syscall/js"

import (
        "fmt"
        "syscall/js"
)

func main() {
        fmt.Println("loaded")
        js.Global()
        js.#
}
2018/09/11 10:56:32 -------------------------------------------------------
2018/09/11 10:56:32 Error parsing input file (outer block):
2018/09/11 10:56:32  /home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go:12:5: expected selector or type assertion, found ';'
2018/09/11 10:56:32 Elapsed duration: 1.676812ms
2018/09/11 10:56:32 Offset: 0
2018/09/11 10:56:32 Number of candidates found: 0
2018/09/11 10:56:32 Candidates are:
2018/09/11 10:56:32 =======================================================
2018/09/11 10:56:44 Got autocompletion request for '/home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go'
2018/09/11 10:56:44 Cursor at: 99
2018/09/11 10:56:44 -------------------------------------------------------
package main

import (
        "fmt"
        "syscall/js"
)

func main() {
        fmt.Println("loaded")
        js.Global()
        f#
}
2018/09/11 10:56:44 -------------------------------------------------------
2018/09/11 10:56:44 Elapsed duration: 1.977122ms
2018/09/11 10:56:44 Offset: 0
2018/09/11 10:56:44 Number of candidates found: 4
2018/09/11 10:56:44 Candidates are:
2018/09/11 10:56:44   const false untyped bool
2018/09/11 10:56:44   package fmt
2018/09/11 10:56:44   type float32 float32
2018/09/11 10:56:44   type float64 float64
2018/09/11 10:56:44 =======================================================
2018/09/11 10:56:44 Got autocompletion request for '/home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go'
2018/09/11 10:56:44 Cursor at: 102
2018/09/11 10:56:44 -------------------------------------------------------
package main

import (
        "fmt"
        "syscall/js"
)

func main() {
        fmt.Println("loaded")
        js.Global()
        fmt.#
}
2018/09/11 10:56:44 -------------------------------------------------------
2018/09/11 10:56:44 Error parsing input file (outer block):
2018/09/11 10:56:44  /home/ef/code/go/src/github.com/eternal-flame-AD/hellowasm/main.go:11:6: expected selector or type assertion, found ';'
2018/09/11 10:56:44 Elapsed duration: 2.87345ms
2018/09/11 10:56:44 Offset: 0
2018/09/11 10:56:44 Number of candidates found: 25
2018/09/11 10:56:44 Candidates are:
2018/09/11 10:56:44   func Errorf(format string, a ...interface{}) error
2018/09/11 10:56:44   func Fprint(w io.Writer, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Fscan(r io.Reader, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Print(a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Printf(format string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Println(a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Scan(a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Scanf(format string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Scanln(a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Sprint(a ...interface{}) string
2018/09/11 10:56:44   func Sprintf(format string, a ...interface{}) string
2018/09/11 10:56:44   func Sprintln(a ...interface{}) string
2018/09/11 10:56:44   func Sscan(str string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Sscanf(str string, format string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   func Sscanln(str string, a ...interface{}) (n int, err error)
2018/09/11 10:56:44   type Formatter interface
2018/09/11 10:56:44   type GoStringer interface
2018/09/11 10:56:44   type ScanState interface
2018/09/11 10:56:44   type Scanner interface
2018/09/11 10:56:44   type State interface
2018/09/11 10:56:44   type Stringer interface
2018/09/11 10:56:44 =======================================================
@myitcv
Copy link

myitcv commented Sep 11, 2018

Edit: switched to using echo instead of cat with heredoc.

This is actually related to #46, but not in a necessarily obvious way.

Here is an example that shows completions working for syscall/js:

export GOPATH=$(mktemp -d)
cd $GOPATH
export PATH=$GOPATH/bin:$PATH
go get github.com/mdempsky/gocode
gocode close
mkdir -p src/example.com/blah
echo -e "package main\nimport \"syscall/js\"\nvar _ = js.\n"> $GOPATH/src/example.com/blah/blah.go
GOOS=js GOARCH=wasm go install syscall/js
GOOS=js GOARCH=wasm gocode -in $GOPATH/src/example.com/blah/blah.go autocomplete $GOPATH/src/example.com/blah/blah.go 44

gives

Found 25 candidates:
  const PreventDefault js.EventCallbackFlag
  const StopImmediatePropagation js.EventCallbackFlag
  const StopPropagation js.EventCallbackFlag
  const TypeBoolean js.Type
  const TypeFunction js.Type
...

Two things to note:

  1. syscall/js under GOOS=js GOARCH=wasm will not be installed by "default" in $GOROOT/pkg/js_wasm/syscall/js.a on any system
  2. the gocode client needs to set GOOS=js GOARCH=wasm in its request

#46 will have the side effect of solving point 1 because of the use of go/packages. But only if point 2 is also true.

For point 2 to be true, we likely require the user's editor to retain some sort of context of the fact that the file/project/whatever needs GOOS=js GOARCH=wasm.

This links back to discussion in https://groups.google.com/forum/#!topic/golang-tools/ZtCU2SteN1w

So in summary; I think this issue can be closed because it's not a bug with gocode; the issues (if they can be described as such) are elsewhere.

cc:
@ianthehat
@ramya-rao-a
@fatih
@joefitzgerald
@zmb3

DisposaBoy added a commit to DisposaBoy/margo that referenced this issue Sep 11, 2018
…l/js

This doesn't fix it for binary imports, but they already don't work properly esp. with the package cache

related: mdempsky/gocode#56
DisposaBoy added a commit to KurokuLabs/margo that referenced this issue Sep 11, 2018
* improve status bar error message when margo.sublime build fails

* make marGocodeCtl a singletone reducer

this also takes cache pruning (partially) out of the QueryCompletions hot path

* improve gsuImporter correctness

make gsuImporter session-based and cache the result ImportFrom to avoid ending up in a loop trying to import a package that just keeps failing

* document that the importFrom() cache also covers pkgInfo()

* remove the now unused nsf/gocode

* trim func bodies in the srcimporter to reduce memory

* srcimporter: add special-case hack to make completion work for syscall/js

This doesn't fix it for binary imports, but they already don't work properly esp. with the package cache

related: mdempsky/gocode#56
@ramya-rao-a
Copy link

@myitcv I tried your steps and I still don't see the completions.

  • I have $GOROOT/pkg/js_wasm/syscall/js.a
  • I've set GOOS=js GOARCH=wasm as env vars
  • I have the latest gocode from mdempsky
  • Am not using modules and go version is go1.11 darwin/amd64

screen shot 2018-09-12 at 9 59 32 pm

Am I missing something?

@eternal-flame-AD has tried the same

@myitcv
Copy link

myitcv commented Sep 13, 2018

@ramya-rao-a the example above is not using modules either.

Perhaps it's an error with the cat heredoc. I've just updated it to use simple echo. Can you give that a try?

@ramya-rao-a
Copy link

ramya-rao-a commented Sep 13, 2018

I skipped the cat/echo and used my editor to write the code in the file in my existing GOPATH :)

@myitcv
Copy link

myitcv commented Sep 17, 2018

@ramya-rao-a if you created the file by hand, is the byte offset (44 in my example) still correct?

@stamblerre
Copy link
Collaborator

I tried reproduce and was able to get completions when setting GOOS and GOARCH in the client request. Closing because this is not a gocode issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants