How can I launch a debug session in VSCode with multiple go files?

huangapple go评论79阅读模式
英文:

How can I launch a debug session in VSCode with multiple go files?

问题

我在main包中有两个.go文件。
我可以使用命令go run main.go plugin.go来运行它们。
我也可以使用dlv来调试它们,命令是dlv debug main.go plugin.go

但是我不知道如何在VSCode中调试它们,因为launch.json文件中的program键只能接受一个go文件作为值。

这是我的launch.json文件:

{
	"name": "player",
	"type": "go",
	"request": "launch",
	"mode": "auto",
	"program": "${workspaceFolder}/playerserver/main.go",
	"args": ["playerserver.conf.json"]
}
英文:

I have two .go files in the main package.
I can run them with command go run main.go plugin.go.
I can also debug them with dlv dlv debug main.go plugin.go.

But I don't know how to debug them in VSCode, since the program key in launch.json can take only one go file as value.

This is my launch.json file

{
		"name": "player",
		"type": "go",
		"request": "launch",
		"mode": "auto",
		"program": "${workspaceFolder}/playerserver/main.go",
		"args": ["playerserver.conf.json"]
}

答案1

得分: 1

param属性设置为指向主包目录。

{
  "name": "player",
  "type": "go",
  "request": "launch",
  "mode": "auto",
  "program": "playerserver",
}

https://github.com/microsoft/vscode-go/issues/1229#issuecomment-473731132

英文:

Set param attribute points to main package directory.

{
  "name": "player",
  "type": "go",
  "request": "launch",
  "mode": "auto",
  "program": "playerserver",
}

https://github.com/microsoft/vscode-go/issues/1229#issuecomment-473731132

huangapple
  • 本文由 发表于 2021年12月28日 10:35:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/70502269.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定