Kate: go debug using delve

Hi all

I’m a long time Kate user, and I recently started to studying Go.

I’m trying to debug code using delve but it seems to not correctly pass the project folder or similar so during the build process it cannot find the go.mod file.

Build Error: go build -o /home/kirys/__debug_bin659773021 -gcflags all=-N -l /home/kirys/Developing/EasyPiam/EasyPiam
go: go.mod file not found in current directory or any parent directory; see 'go help modules' (exit status 1)

I tried to add a custom config to pass the workdir without success (I attach here only the delve part relevant, the full json is valid and the ide shows the custom profile)

                "go launch (debug)": {
                    "request": {
                        "command": "launch",
                        "mode": "debug",
                        "program": "${file}",
                        "cwd": "${workdir}",
                        "args": "${args|list}"
                    }
                },

My custom profile pass the cwd value during the request phase

    "request": {
        "args": [
        ],
        "command": "launch",
        "cwd": "/home/kirys/Developing/EasyPiam",
        "mode": "debug",
        "program": "/home/kirys/Developing/EasyPiam/EasyPiam"
    },

But the result doesn’t change

delve works from the command line (dlv debug)

delve is 1.26.1

kate is 25.12.3

fedora 43

Is there someone that can hint me on how to make it work?

Thank You

K.

You don’t need to do that. The default profile/config should work for you.

The above $file, $workdir means that you need to supply these keys in the UI for every target. You can have multiple targets:

You can also use .vscode/launch.json file to supply “targets” to debug. Simply create a directory .vscode at the root of your project. Create a launch.json file in that project:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Delveb",
            "request": "launch",
            "debuggerProfile": "launch (exec)",
            "program": "/path/to/your/program",
            "args": [],
            "type": "delve"
        }
    ]
}

The type key should match the “debugger” key in the settings. debuggerProfile should also match an existing profile in the settings. You can reload the config by clicking the 4th button below target name, or just delete all the targets and then click that refresh button.

Hope this helps

First thank you for your answer

I know it should but it doesn’t (at least not for me)

this is the profile with my custom one bu the result is the same with both

It seems runs the build process from my home folder instead of the project folder. So go cannot find the go.mod file during build.

I’ll try create the .vscode file (kate read those?) and let you know.

Bye

K.

I’ve found a workaround (I guess)

I’ve changed the config this way

                "go launch (debug)": {
                    "request": {
                        "command": "launch",
                        "mode": "debug",
                        "program": "${file}",
                        "dlvCwd": "${workdir}",
                        "args": "${args|list}"
                    }
                },

and configured the profile this way

And this seems to work

I was wondering why I need to do this and why the defaults don’t work.

But I think that maybe the issue is that the debug mode want to runs go build. And kate configuration probably expect to have the legacy GOPATH location properly set to work.

Bye

K.