# Setting breakpoints for Golang

**URL:** <https://discourse.sst.dev/t/setting-breakpoints-for-golang/2830>\
**Category:** Chapter Comments\
**Created:** [June 20, 2023, 9:48am UTC](https://discourse.sst.dev/t/setting-breakpoints-for-golang/2830 "2023-06-20T09:48:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![menfre](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@menfre](https://discourse.sst.dev/u/menfre)\
**Post date:** [June 20, 2023, 9:48am UTC](https://discourse.sst.dev/t/setting-breakpoints-for-golang/2830/1 "2023-06-20T09:48:53Z")

</div>

Since sst do not support golang setting breakpoints yet, I need a way to debugging golang.

1. install dlv
2. setting launch.json

```json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Go Handler",
      "type": "go",
      "debugAdapter": "dlv-dap", 
      "request": "attach",
      "mode": "remote",
      "port": 2345,
      "host": "127.0.0.1", 
      "substitutePath": [
        {
          "from": "${workspaceFolder}/functions/lambda",
          "to": "${workspaceFolder}/functions/lambda"
        },
      ]
    },
    {
      "name": "Debug SST Dev",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/sst",
      "runtimeArgs": [
        "dev",
        "--increase-timeout"
      ],
      "console": "integratedTerminal",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "env": {}
    }
  ]
}

```

1. replace node\_modules/sst/runtime/handlers/go.js for it’s line 28, inside startWorker function

```javascript
...
            const proc = spawn( 
                "dlv",
            [
                "exec",
                "--listen=:2345",
                "--headless",
                "--api-version=2",
                path.join(input.out, handlerName)
            ],
            {
                env: {
                    ...process.env,
                    ...input.environment,
                    IS_LOCAL: "true",
                    AWS_LAMBDA_RUNTIME_API: `localhost:${server.port}/${input.workerID}`,
                },
                cwd: input.out,
            });
...

```

1. run Debug SST Dev configuration, and then trigger lambda, it will hold the process at port 2345 waiting for client connect, run Debug Go Handler to connect
