Visual studio code 如何在launch.json中配置vs代码工作目录

Visual studio code 如何在launch.json中配置vs代码工作目录,visual-studio-code,Visual Studio Code,我使用goland(与webstorm/intellij等相同)IDE,在调试配置中,有一个地方可以配置工作目录,现在我尝试使用VSCODE,但我没有找到这个配置,经过一点研究,我找到了下面的json,它应该可以处理这个问题,但没有找到工作目录的正确位置 e、 这是我的工作目录 /Users/i022226/go/src/myapp "configurations": [{ "name": "Launch Package", "type": "go

我使用goland(与webstorm/intellij等相同)IDE,在调试配置中,有一个地方可以配置
工作目录
,现在我尝试使用VSCODE,但我没有找到这个配置,经过一点研究,我找到了下面的json,它应该可以处理这个问题,但没有找到工作目录的正确位置

e、 这是我的工作目录

/Users/i022226/go/src/myapp

"configurations": [{
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true
        } 
launch.json
中有添加配置按钮,当我键入
cwd
时,我没有得到任何条目,知道吗

在这篇文章中,
cwd
选项下,但我找不到
选项

您应该像下面那样添加它

    {
        "name": "Launch",
        "type": "go",
        "request": "launch",
        "mode": "debug",
        "cwd": "Your Path",
        "remotePath": "",
        "port": 2345,
        "host": "127.0.0.1",
        "program": "${fileDirname}",
        "env": {},
        "args": [],
        "showLog": true
    }

下面是一个示例
launch.json
,用于基于以下内容在项目子文件夹中运行Python模块:


请注意,
cwd
必须位于
args
之前,否则它将不起作用。

有一个
launch.json
文件…在那里,您应该能够设置
cwd
属性…(
cwd
代表
当前工作目录
)@Hackerman-我在问题中输入的json是launch.json;),我没有看到任何
cwd
在那里,有什么想法?>]有更多的选项可供选择,而不是显示在一个默认的预先制作的任务上。尝试在任务中键入“cwd”,您将看到提示。@标记-尝试不成功,我在启动时单击“添加配置”时找不到cwd。json这与我的情况不完全一致,但关键信息是:键是
“cwd”
,一个有用的变量是
${fileDirname}
。。。
{
    // 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": "Python: Launch",
            "type": "python",
            "request": "launch",
            "module": "module_source_folder.filename",
            "cwd": "${workspaceFolder}/examples/folder_with_test_files",
            "args": ["-f", "input_filename"]
        }
    ]
}