New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go Lang debugging not working in VSCode using sam cli #1376
Comments
I just tried the below steps debugger is not attaching in VS code .. but code is working |
C:\go-work\src\sam-app1\sam-app>sam local start-api -d 5989 --debugger-path . --debug-args="-delveAPI=2" Fetching lambci/lambda:go1.x Docker container image...... It get strucked after this . |
If anyone run into this, the issue here is that the dlv that you've built is not compatible with the OS that your code runs on. Step 1Install a dlv binary that's compatible with the OS that your code is going to run on. For me, my native OS is macOS, and I need to run go code in linux. With go 1.16, I did
This installed a Step 2Set your
Now run the |
i tried the same in visual studio code for go lang .. I am getting the below error
{
"errorMessage": "fork/exec /tmp/lambci_debug_files/dlv: exec format error",
"errorType": "PathError"
}?[0m
2019-08-27 17:42:43 Function returned an invalid response (must include one of: body, headers, multiValueHeaders or statusCode in the response object).
Note:
I modifed Handler name to main in template.yaml
I created the project through sam init --runtime go1.x
Installed docker ...
in my docker images i have lambci/lambdaimage only.
Below command are used :
set GOARCH=amd64
set GOOS=linux
mkdir debugger
go build -gcflags "all=-N -l" -o ./debugger/dlv github.com/go-delve/delve/cmd/dlv
go build -gcflags "all=-N -l" -o hello-world/hello-world ./hello-world
sam local start-api -d 5987 --debugger-path ./debugger --debug-args="-delveAPI=2"
PFA my template.yaml file and launch.json file.
template.txt
{
// 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",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "",
"port": 5988,
"host": "127.0.0.1"
// "program": "${fileDirname}",
// "env": {},
// "args": []
}
]
}
whether i need to run dlv in my container and need to point out in build command ? If so kindly give some example.
template.txt
The text was updated successfully, but these errors were encountered: