Skip to content

Commit fb092e6

Browse files
gongzhxugongzhangxun
authored andcommitted
feat: add dlvflag for golang debug
1 parent e753157 commit fb092e6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

v2/cmd/wails/flags/dev.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Dev struct {
3131
AppArgs string `flag:"appargs" description:"arguments to pass to the underlying app (quoted and space separated)"`
3232
Save bool `flag:"save" description:"Save the given flags as defaults"`
3333
FrontendDevServerURL string `flag:"frontenddevserverurl" description:"The url of the external frontend dev server to use"`
34+
DlvFlag string `flag:"dlvflag" description:"Flags to pass to dlv"`
3435

3536
// Internal state
3637
devServerURL *url.URL

v2/cmd/wails/internal/dev/dev.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,22 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
309309
os.Setenv("frontenddevserverurl", f.FrontendDevServerURL)
310310

311311
// Start up new binary with correct args
312-
newProcess := process.NewProcess(appBinary, args...)
312+
313+
var command string
314+
if len(f.DlvFlag) == 0 {
315+
command = appBinary
316+
} else {
317+
command = "dlv"
318+
newArgs := append(strings.Split(f.DlvFlag, " "), "exec", appBinary)
319+
if len(args) > 0 {
320+
newArgs = append(newArgs, "--")
321+
args = append(newArgs, args...)
322+
}
323+
args = newArgs
324+
}
325+
326+
logutils.LogGreen("Executing: " + command + " " + strings.Join(args, " "))
327+
newProcess := process.NewProcess(command, args...)
313328
err = newProcess.Start(exitCodeChannel)
314329
if err != nil {
315330
// Remove binary

0 commit comments

Comments
 (0)