-
Notifications
You must be signed in to change notification settings - Fork 645
"could not import syscall/js" error message even though it builds and runs successfully #1874
Comments
I reopened the project to investigate further and when I moused over the import with it's red squiggly line, I got this error:
I think the plugin doesn't use an altered GOOS and GOARCH when checking the code for errors. I tried setting |
In Output I see:
I've set my go.toolsEnvVars as follows:
GoRoot and GoPath reflect what the normal env variables are. I'm still getting the Adding write privileges to the $GOROOT/pkg folder not only feels like a bad move, but it also doesn't entirely fix the problem. The error goes away but there's no intellisense for anything under |
Experiencing the same issue. |
- syscall/jsでエラーが出るのを避ける - エラーは出ないがmetthodの予測は出ないままなのでさらなる対応が必要 - relation : microsoft/vscode-go#1874
- syscall/jsでエラーが出るのを避ける - エラーは出ないがmetthodの予測は出ないままなのでさらなる対応が必要 - relation : microsoft/vscode-go#1874 demo: js operation - goから操作するのはsyscall/jsのAPIを通して文字列でjsのprop/methodを呼び出す - Dom操作APIの作成か、Dom操作周りのwrapperを書くのが早いかどちらだろう
- syscall/jsでエラーが出るのを避ける - エラーは出ないがmetthodの予測は出ないままなのでさらなる対応が必要 - relation : microsoft/vscode-go#1874
Can you try adding the setting |
@ramya-rao-a Thanks, I followed your steps and the error is not coming out. However, there is still no IntelliSense for |
If the results from |
It indeed said zero candidates. I guess that's an upstream issue then. |
Are you using modules? And why is the GOPATH being set to |
It should be I'll try setting env variables like you suggest when I get a chance. |
|
I tried setting env before starting gocode but it is still not spawning candidates :( |
@eternal-flame-AD You still didn't mention if you were using the new modules feature or not :) @coreyog What about you? Are you using modules? |
No, I am not. As shown by my minimal code sample above. |
@coreyog And you are able to get out of the initial error reporting by VS Code like @eternal-flame-AD ? Can you check your $GOROOT/pkg? Do you have a folder there for |
I was NOT using modules. :) @ramya-rao-a |
@eternal-flame-AD @coreyog If you don't have |
I ran the command and |
@eternal-flame-AD Ensure GOOS and GOARCH are js, wasm and retry Do you see zero candidates still? |
Yep I think the problem was still there:(
|
@eternal-flame-AD Last question. You have set GOOS and GOARCH to js and wasm in the toolsEnvVars setting right?
|
|
Ok, I am running out of ideas, lets take this up in mdempsky/gocode#56 |
This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions. |
I think this issue should be reopened. I dug a little through the vscode-go code and found this line which masked all https://github.com/Microsoft/vscode-go/blob/d1a9f9a8cd7428c552517d72af148b7b116b9ed0/src/goSuggest.ts#L185 |
I am not sure how to reproduce the issue mentioned on the code comments before this line. However I think we should definitely at least add an exception for |
That's a great find @eternal-flame-AD! The commit behind that change is f73f41d which was made as part of the PR #156 to fix the issue #140 @stamblerre Any idea if the comment in the above commit still holds true? @eternal-flame-AD Can you try cross-compiling with say linux and see if your fix still works? |
@ramya-rao-a: gocode tracks the build.Context of requests, so if you explicitly set |
Thanks @stamblerre! @eternal-flame-AD Would you be interested in submitting a PR to fix this? |
Yep. I found that when I found a solution to the problem that is enabling source import when spawning gocode daemon. Should we include this change in the PR? diff --git a/src/goSuggest.ts b/src/goSuggest.ts
index a5d9e66..40a63d1 100644
--- a/src/goSuggest.ts
+++ b/src/goSuggest.ts
@@ -187,14 +187,11 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
return reject();
}
- // Unset GOOS and GOARCH for the `gocode` process to ensure that GOHOSTOS and GOHOSTARCH
- // are used as the target operating system and architecture. `gocode` is unable to provide
- // autocompletion when the Go environment is configured for cross compilation.
- let env = Object.assign({}, getToolsEnvVars(), { GOOS: '', GOARCH: '' });
+ let env = Object.assign({}, getToolsEnvVars());
let stdout = '';
let stderr = '';
- let goCodeFlags = ['-f=json'];
+ let goCodeFlags = ['-f=json','-source=true'];
if (!this.setGocodeOptions) {
goCodeFlags.push('-builtin');
}
|
Including the Are you saying that if you add the |
Yeah. Or maybe only enabling this when cross compiling? |
I think we could move this discussion to #2015 as the corrent topic is more related to detailed implementation of the fix. |
The fix for this issue is now out in the latest update to the Go extension (0.6.92). Thanks @eternal-flame-AD and @stamblerre! Note: Part of the fix here is in |
When built with
GOOS=js GOARCH=wasm go build main.go
using Go 1.11 this produces a WASM binary without error. However VSCode shows that there's an error:I think this has to do with that namespace being experimental while wasm support stabilizes over the coming versions. I'm given very little details about the error.
As a result of the namespace not being found, intellisense also doesn't work.
I'm running VSCode 1.26.1 on Linux Mint 19 x64 with Go 1.11
The text was updated successfully, but these errors were encountered: