且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Visual Studio代码(vscode)中调试Revel Framework(golang)应用程序

更新时间:2022-01-16 09:10:46

以下是在vscode中调试Revel框架(golang)应用的步骤.

Here are the steps to debug a revel framework (golang) app in vscode.

  1. 将revel项目文件夹导入vscode
  2. 编辑〜/.vscode/launch.json,使其类似于以下内容:(将<>中的值替换为您自己的本地环境的值.

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "remotePath": "", "port": 2345, "host": "127.0.0.1", "mode": "debug", "program": "${workspaceRoot}/app/tmp/", "env": {}, "args": ["-importPath", "<project folder name>", "-srcPath", "C:\\Users\\<username>\\go\\src", "-runMode", "dev"] } ] }

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "remotePath": "", "port": 2345, "host": "127.0.0.1", "mode": "debug", "program": "${workspaceRoot}/app/tmp/", "env": {}, "args": ["-importPath", "<project folder name>", "-srcPath", "C:\\Users\\<username>\\go\\src", "-runMode", "dev"] } ] }

请注意-importPath应该是目录(相对于项目所在的$ GOPATH \ src)

Note that -importPath should be the directory (relative to $GOPATH\src where your project lives)

请注意,-srcPath的值应与$ GOPATH \ src目录匹配(我在Windows上运行)

Note that the value for -srcPath should match your $GOPATH\src directory (I'm running on Windows)

一旦这样设置了launch.json,就可以以deb模式启动该应用,并在任意位置放置断点.

Once your launch.json is set up as so, you can start the app in deb mode and put breakpoints wherever you wish.