-
Notifications
You must be signed in to change notification settings - Fork 645
add support for the experimental version of gocode running on go/packages #1932
Conversation
cp.execFile(goRuntimePath, ['get', '-u', '-v', allTools[tool]], { env: envForTools }, (err, stdout, stderr) => { | ||
let args = ['get', '-u', '-v']; | ||
if (tool.endsWith('-gomod')) { | ||
args.push('-d'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we choosing to not install and instead run a go build later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only "go build" has the -o flag that allows us to rename the binary to "gocode-gomod" instead of gocode, so I don't think there is a way to "go get" and rename the tool with one command.
@stamblerre Thanks for the PR! I have refactored the code in Will test it out tomorrow and merge it. |
It seems like the broken build is a result of an error in "fillStruct", which I don't think is related to this change. |
@ramya-rao-a - just wanted to follow up, does this change seem ready to you? |
Yes, this looks good. I wanted to make general changes on how to identify whether mod is supported and cache the results as well, but I can do that in the master branch. I'll have a test build ready soon. Thanks! |
For more information see: microsoft/vscode-go#1932
I'm currently working on adding I'll check it again once I'm back in town. |
Thanks for merging @ramya-rao-a. I'll probably have a similar PR soon for you for godef. Let me know if there are any problems with it. |
I am seeing similar things as @fatih. I just have a simple file with just 1 non std lib package dependency. It worked well for the past hour, but now I get "null" as the output from To test it out in VS Code:
|
I'm not sure if this will help fully, but I just pushed stamblerre/gocode@b960ec2, which should allow regular gocode and gocode-gomod run simultaneously. I'll try to keep using it though to see if I can find more problems. |
@stamblerre Anything we can do to help debug the issue where gocode returns the string "null"? |
I haven't been able to reproduce that yet, but I am using gocode-gomod right now and trying to see if I can get it to happen. If you run "gocode-gomod close" and then "gocode-gomod -s -debug", and then try a completion and see what it prints out, that might give some useful information. Thanks! |
@stamblerre Below is the output from
|
I know the repro steps for the failure now. In the above example, I am using the
On every file save, we run @fatih Do you see something similar? |
Oh, so is the only problem you're seeing related to completing with unsaved imports? |
Yes, looks like that |
Ok, I will try to investigate this error and see if I can resolve it. Though this doesn't seem like a huge deal to me--the pretty simple solution is to add the import back. |
if (stderr.indexOf('unexpected directory layout:') > -1) { | ||
outputChannel.appendLine(`Installing ${tool} failed with error "unexpected directory layout". Retrying...`); | ||
cp.execFile(goRuntimePath, ['get', '-u', '-v', allTools[tool]], { env: envForTools }, callback); | ||
cp.execFile(goRuntimePath, args, { env: envForTools }, callback); | ||
} else if (tool.endsWith('-gomod')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll never pass this in my tests. see #2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dexus Did you try the latest from master?
You need to update either of gocode-gomod
or godef-gomod
via the Go: Install/Update Tools
command to hit this else
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in #2024 already pointed out I fix it myself with a copy. Would be nice if the current fix will be published asap. That works for me.
For more information see: microsoft/vscode-go#1932
This PR adds support for installing and switching between the regular version of certain Go tools and the versions that run on-top of go/packages (which works with Modules).
If the user is in a directory with a go.mod file,
gocode-gomod
will be executed, whereas if the user is in a normal$GOPATH
workspace, the normal version will be executed. This allows users to test out their usual Go tools with Modules, while avoiding any bugs that may still be present, since these tools are still quite new.For now, only gocode switches between
gocode-gomod
andgocode
.godef-gomod
can be downloaded, but it's not yet added in this change. Ideally, the version of the tool to run should be decided in a function likegetBinPath
, but I wanted to test one tool before using that approach.