# How to debug go backend on windows?

**URL:** <https://community.grafana.com/t/how-to-debug-go-backend-on-windows/112628>\
**Category:** Grafana Plugin Development\
**Created:** [January 23, 2024, 4:10pm UTC](https://community.grafana.com/t/how-to-debug-go-backend-on-windows/112628 "2024-01-23T16:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwiehler](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mwiehler](https://community.grafana.com/u/mwiehler)\
**Post date:** [January 23, 2024, 4:10pm UTC](https://community.grafana.com/t/how-to-debug-go-backend-on-windows/112628/1 "2024-01-23T16:10:18Z")

</div>

I’m currently developing a grafana datasource with http backend plugin!  
I’m developing on a Windows machine, with a WSL2 Alpine distribution setup. The Alpine distro has go, nodejs etc. set up, aswell as docker.  
I’m using VSCode to develop on my windows machine.

I’ve successfully scaffolded the plugin and made some changes in the react frontend.  
Since I’m now at the stage of developing my go backend, I’ve wanted to debug to see what is going on, however I’m not able to get breakpoints working in VSCode.  
What I’ve tried:

- Extended Dockerfile to install delve debugger

- Extended docker-compose-yaml to not only mount the dist and provisioning directories, but also the pkg directory so delve has acces to the code and to expose the port to connect to delve

- Setup a lauch profile in VS Code to attach to delve via remote

```json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug in Container",
      "type": "go",
      "request": "attach",
      "mode": "remote",
      "remotePath": "/var/lib/grafana/plugins/company-mongodbconnector-datasource/pkg",
      "port": 2345,
      "host": "127.0.0.1",
      "apiVersion": 2,
      "trace": "verbose",

    }
  ]
}

```

The VSCode logfile states, that breakpoints have been set successfully, however they never break execution. All that happens is, that my datasource doesn’t load anymore, when delve is attached to the go plugin.

Is there a better way to debug on Windows machine?

---

<div class="post-metadata">

**Author:** ![mwiehler](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mwiehler](https://community.grafana.com/u/mwiehler)\
**Post date:** [January 25, 2024, 2:16pm UTC](https://community.grafana.com/t/how-to-debug-go-backend-on-windows/112628/2 "2024-01-25T14:16:24Z")

</div>

I managed to make it work by setting the “cwd” and “remotePath” properties correctly

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [January 24, 2025, 2:16pm UTC](https://community.grafana.com/t/how-to-debug-go-backend-on-windows/112628/3 "2025-01-24T14:16:51Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
