vscode: how to debug golang in live-share mode - go

When livesharing my code with golang, I could not start debugging mode (i'm using delv)
Here is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"debugAdapter": "dlv-dap",
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "./main.go",
"args": ["server"]
}
]
}

Related

Debug Blazor Server in VSCode

launch.json:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "msedge",
"request": "launch",
"preLaunchTask": "build",
"cwd": "${workspaceFolder}",
"webRoot": "${workspaceFolder}",
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
// },
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5000"
},
"sourceMaps": true,
//"url": "http://localhost:5000",
// If you have changed the default port / launch URL make sure to update the expectation below
//"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
and tasks.json:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "dotnet",
//"group": "build",
"args": [
"watch",
"run",
"${workspaceFolder}/BlazorStore9.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
// "presentation": {
// // Reveal the output only if unrecognized errors occur.
// "reveal": "silent"
// },
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile",
"options": {"cwd": "${workspaceFolder}"}
}
]
This only launches site for browsing but not debug, How to correct these files for debug?
I removed "request": "launch", from launch.json and debug works.

Error when debugging my Laravel Application in VSCode using Xdebug

I am trying to debug my Laravel application running with Sail using Xdebug in VSCode. But I am getting this error when debug my application.
Here is my launch.json file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
},
]
}
Is anyone know what is the problem for this? Thanks you so much!

Debug Cake Frosting project in VSCode

I found an old question related to debugging a cake script in vscode.
How do I debug a "frosting" project?
I added this to .vscode/launch.json, but it runs the project without stopping at breakpoints:
{
"name": "cake",
"type": "coreclr",
"request": "launch",
"cwd": "${workspaceFolder}/build",
"program": "dotnet",
"args": [ "run" ],
"stopAtEntry": false
}
One must run the frosting console programme (Build.dll).
.vscode/tasks.json:
{
"label": "build-cake",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/build/Build.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
.vscode/launch.json
{
"name": "cake",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-cake",
"cwd": "${workspaceFolder}/build",
"program": "${workspaceFolder}/build/bin/Debug/net6.0/Build.dll",
"args": [],
"console": "internalConsole",
"stopAtEntry": false
}

Debug when run a folder

I have a folder called cmd.
When I want to run my program, I need to run the command.
go run cmd/*.go server where server is an argument.
But I don't know how to setup the debugging for my program in VsCode.
I have tried these configurations but none of these works.
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/main.go cmd/initialize.go cmd/commands.go cmd/pubsub_action.go", // all go files in the cmd directory
"cwd": "${workspace}",
"args": [
"server"
]
}
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/*go",
"cwd": "${workspace}",
"args": [
"server"
]
}
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/*",
"cwd": "${workspace}",
"args": [
"server"
]
}
The question is, what is the correct way to run debugging for my application?
Found the solution.
{
"name": "Launch Package Test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd",
"cwd": "${workspace}",
"args": [
"server"
]
}
Set the program to cmd

How to debug in VSCode

I have a problem with the Golang debugger in Visual Studio Code.
My launch.json:
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"port": 2345,
"host": "127.0.0.1",
"env": {},
"args": []
}
]
I put a breakpoint, I launch the debugger, it start up and write to the Debug Console:
API server listening at: 127.0.0.1:2345
and nothing else happens!
Thanks in advance for your help!

Resources