如何在外部控制台中启动/调试项目?

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

How do I launch/debug a project in an external console?

问题

我正在尝试在VSCode中调试一个Go项目。我能够进行调试,但应用程序在内部的VSCode终端中运行。我希望应用程序在外部控制台中运行,例如在cmd.exe中运行。

你可以通过修改launch.json文件来实现在外部控制台中运行调试会话,而不是在VSCode的内部控制台中运行。你可以按照以下步骤进行操作:

  1. 打开项目中的.vscode文件夹。
  2. 打开launch.json文件。
  3. 在configurations数组中的"Launch Package"对象中添加一个新的属性"console",并将其值设置为"externalTerminal",如下所示:
{
    "name": "Launch Package",
    "type": "go",
    "request": "launch",
    "mode": "auto",
    "program": "${fileDirname}",
    "console": "externalTerminal"
}
  1. 保存launch.json文件。

这样,当你进行调试时,调试会话将在外部控制台中打开并运行。

希望对你有帮助!如果你还有其他问题,请随时问我。

英文:

I am trying to debug a Go project in VSCode. I am able to debug it, but the application is running in the internal VSCode terminal. I need the application to run in an external console instead. For instance I want it to run in cmd.exe.

// .vscode/launch.json
{
	// 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": "Launch Package",
			"type": "go",
			"request": "launch",
			"mode": "auto",
			"program": "${fileDirname}"
		}
	]
}

How can I make the debug session open a external console and run it there, rather than in the internal console of VSCode?

答案1

得分: 0

Go VSCode扩展的开发人员正在添加一个启动属性。请参阅:https://github.com/golang/vscode-go/issues/124#issuecomment-1006122877

英文:

The developers for the Go VSCode extension are in the process of adding a launch property for this. See: https://github.com/golang/vscode-go/issues/124#issuecomment-1006122877

huangapple
  • 本文由 发表于 2022年1月19日 15:04:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/70766494.html
匿名

发表评论

匿名网友

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

确定