From 40b1b625026af410afa76729aa3a1b71e11c5d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Thu, 13 Mar 2025 11:10:07 +0100 Subject: [PATCH] improve the debugging experience (#101779) improve debugging experience --- .vscode/launch.json | 5 +++++ pkg/build/cmd.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 67c4f82699b..50393b02272 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,6 +11,11 @@ "cwd": "${workspaceFolder}", "args": ["server", "--homepath", "${workspaceFolder}", "--packaging", "dev", "cfg:app_mode=development"] }, + { + "name": "Attach to Go Process", + "type": "go", + "request": "attach" + }, { "name": "Attach to Test Process", "type": "go", diff --git a/pkg/build/cmd.go b/pkg/build/cmd.go index 9796a1428da..226bd15245f 100644 --- a/pkg/build/cmd.go +++ b/pkg/build/cmd.go @@ -185,6 +185,11 @@ func doBuild(binaryName, pkg string, opts BuildOpts) error { args := []string{"build", "-ldflags", lf} + if opts.isDev { + // disable optimizations, so debugger will work + args = append(args, "-gcflags", "all=-N -l") + } + if opts.goos == GoOSWindows { // Work around a linking error on Windows: "export ordinal too large" args = append(args, "-buildmode=exe")