Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Does vscode-go support debug go code using go plugin? #3048

Closed
morningspace opened this issue Feb 13, 2020 · 5 comments
Closed

Does vscode-go support debug go code using go plugin? #3048

morningspace opened this issue Feb 13, 2020 · 5 comments

Comments

@morningspace
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.13.6 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.42.0
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.13.0
  • Run go env GOOS GOARCH to get the operating system and processor arhcitecture details
    • darwin
    • amd64

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] prefixes.
{
"terminal.integrated.shell.osx": "/bin/bash",
"go.useLanguageServer": true,
"window.zoomLevel": -1,
}

Describe the bug

I have a module built by go plugin. And I want to load the plugin in my main module, and debug the main code in vscode using go extension.

However, I can always see below error when it goes to the line to load the plugin using plugin.Open():

plugin.Open("/path/to/my/plugin"): plugin was built with a different version of package runtime/internal/sys

While, if I build and run the code outside vscode on the same machine, it works w/o any problem.

As I know, usually, go plugin load failure like this is caused by plugin and main code using different golang release, GOPATH, etc. However, I've checked that they are all the same.

Does vscode-go support debug go code using go plugin? Any idea of how to troubleshoot this issue?

@hyangah
Copy link
Contributor

hyangah commented Feb 13, 2020

@morningspace does the program run without an error if you build/run the program outside vscode, and debug directly using delve? I see many open bugs and similar bug reports about plugin in upstream go project. So, maybe testing by eliminating the vscode or vscode-go is the first step to narrow down the scope of the problem.

golang/go#27751 (which uses module) and many others linked from there.

@morningspace
Copy link
Author

@hyangah Thanks for your prompt help... to try outside vscode and debug directly using delve is a really good idea. It can help me identify the cause further. I will circle back here when I have updates!

@jasondu168
Copy link

In my case, go test can run the program but when debugging with debug test in vscode, it will throw an error plugin was built with a different version of package runtime/internal/sys

@morningspace
Copy link
Author

Hi, I've managed to make it work after reading this. So, it's not an issue of vscode-go, but an "issue" of the upstream project delv. After I use -gcflags='all=-N -l' to build both the plugin and the main module, I can successfully debug it both by delv in terminal and vscode.

@jdu-mydevices You can have a try.

I'd be happy to close this issue if that works for others.

@stamblerre
Copy link
Contributor

Glad you were able to resolve the issue, @morningspace. @jdu-mydevices: Please file a new issue if your problem persists. I'll go ahead and close this one. Thanks!

arihantdaga added a commit to arihantdaga/volantmq that referenced this issue Apr 4, 2020
- We have to compile the plugins also with the -gcflags='all=-N -l' according to this issue microsoft/vscode-go#3048 (comment)
@vscodebot vscodebot bot locked and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants