Summary
I made golang application by AWS SAM.
Now I try to debug this sample application in VSCode.
But It fails so I want to know how to correctly debug it.
Tried
toggl-slack
├── Makefile
├── README.md
├── dlv
├── samconfig.toml
├── hello-world
│ ├── main.go
│ └── main_test.go
└── template.yaml
I put following command on console for debug.
cd toggl-slack
go get -u github.com/go-delve/delve/cmd/dlv
GOARCH=amd64 GOOS=linux go build -o ./dlv github.com/go-delve/delve/cmd/dlv
GOARCH=amd64 GOOS=linux go build -gcflags='-N -l' -o hello-world/hello-world ./hello-world
sam local start-api -d 5986 --debugger-path . --debug-args="-delveAPI=2"
curl http://127.0.0.1:3000/hello
As result, debug does not work and console shows error message.
Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2019-12-28 21:23:17 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
Invoking hello-world (go1.x)
Fetching lambci/lambda:go1.x Docker container image......
Mounting /Users/jpskgc/toggl-slack/hello-world as /var/task:ro,delegated inside runtime container
Could not create config directory: mkdir /home/sbx_user1051: permission denied.API server listening at: [::]:5986
2019-12-28T12:23:46Z info layer=debugger launching process with args: [/var/task/hello-world]
2019-12-28T12:23:47Z warning layer=debugger reading debug_info: could not find abstract origin (0x13ed31) of inlined call at 0xfab50
Codes
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Connect to Lambda container",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "",
"port": 5986,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": []
}
]
}
Other code is same as default sample application for AWS SAM.
Full Source Code is here:
https://github.com/jpskgc/toggl-slack