Home > Backend Development > Golang > How to configure Delve (dlv) in VS Code

How to configure Delve (dlv) in VS Code

Linda Hamilton
Release: 2024-12-01 12:27:18
Original
464 people have browsed it

Let's have delve integrated with VS Code!

First you need to install Delve (dlv):

go install github.com/go-delve/delve/cmd/dlv@latest
Copy after login

You can verify where it was installed by running:

which dlv
Copy after login

Then in Visual Studio Code you need to go to Settings and search "delve". You will find Go: Delve Config.

How to configure Delve (dlv) in VS Code

Click on "Edit in settings.json".

Add the path to dlv you obtained before:

"go.delveConfig": {
    "dlvPath":"/Users/<user>/go/bin/dlv"
}
Copy after login

Finally, in the launch.json file add the configuration for launching the debugger.

Adapt "program" and "envFile" to point to the values needed in your project.

Here an example:

"configurations": [
    {
        "name":"Launch",
        "type": "go",
        "request": "launch",
        "mode": "debug",
        "program": "${workspaceFolder}/.../main.go",
        "envFile": "${workspaceFolder}/.../.env"
    }
]
Copy after login

You can now run in debug mode your program by pressing F5 key.

I hope you will find this setup helpful.

The above is the detailed content of How to configure Delve (dlv) in VS Code. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template