Open JCzz opened 6 months ago
CC @hyangah @suzmue
Can you please share your settings.json?
I only have: "go.toolsManagement.autoUpdate": true,
in my settings.json file
Can you check if the environment variables and the go command shown in "Go: Locate Configured Go Tools" match the env var and go command used when you were building the plugin?
Good question @hyangah
VSCode:
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/go-build1156416228=/tmp/go-build -gno-record-gcc-switches -fno-common'
Go env:
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/go-build53071494=/tmp/go-build -gno-record-gcc-switches -fno-common'
From the above very long line, there is a difference in: VSCode / go env: -ffile-prefix-map=/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/go-build1156416228=/tmp/go-build -ffile-prefix-map=/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/go-build53071494=/tmp/go-build
Do GOROOT values & path to the go command match?
Yes, only "-ffile-prefix-map=/var/folders/.......=/tmp/go-build" described above mismatch
That is a temporary directory so I doubt that matters. I don't know what makes the difference but you can try to pass build flags to the go command and the delve and compare what's going on.
For go command used for building the plugin, use -x -v to see details.
For delve, add that -x -v flags to buildFlags
https://github.com/golang/vscode-go/wiki/debugging#configuration in the launch configuration, and add fields to enable logging (https://github.com/golang/vscode-go/wiki/debugging#collect-logs). That will print build details in DEBUG OUTPUT tab.
Unable to set it up correctly, can you please help - thanks.
Tried the following:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"showLog": true,
"logOutput": "dap",
"buildFlags": [
]
},
]
}
But I dont know how to "For delve, add that -x -v flags to buildFlags"?
Thanks in advance
Hi there
I am compiling golang plugin from code, and then read in the plugin again - for reading in code dynamic.
This works great from the terminal, but the problem is that when reading in the plugin using vscode debugger, the build flags are not the same as when I build the plugin.
Example:
commands := []string{"build", "-buildmode=plugin", "-o", pluginPathSo, pluginPathGo}
plug, err := plugin.Open(path)
I get "plugin was built with a different version of package internal"Problem
I can solve the problem using the same build flags as vscode, when building my plugin, but I dont know what build flags vscode is using?