20

I use goland(same as webstorm/intellij etc) IDE and in debug configuration there is a place when you can configure working directory Now I try to work with VSCODE and I dont find this configuration , after a bit research I find the following json which should handle this but dont find the right place for working directory

e.g. this is my working directory

/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
        } 

In the launch.json there is add configuration button and when I type cwd I dont get any entry, any idea ?

In this post the cwd is under the option but I dont find the option https://github.com/Microsoft/vscode/issues/856

4
  • 2
    There is a launch.json file...there you should be able to set the cwd property...(cwd stands for current working directory)
    – Hackerman
    Commented Nov 28, 2017 at 20:50
  • @Hackerman - The json that I put in the question is the launch.json ;) , I dont see any cwd there, any idea?>] Commented Nov 28, 2017 at 20:53
  • There are more options available than are shown on one of the default pre-made tasks. Try typing "cwd" within a task and you will see it prompted.
    – Mark
    Commented Nov 28, 2017 at 23:04
  • @Mark - Try it without success , I dont find the cwd when I click on add configuration on the launch.json Commented Nov 29, 2017 at 7:06

2 Answers 2

13

Here's an example launch.json to run a Python module in a project subfolder based on Tals's answer:

{
    "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"]
        }
    ]
}

Note that cwd must come before args or it won't work.

10

You should add it like following

    {
        "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
    }
1
  • 6
    This doesn't correspond to my case exactly, but the key informations were: the key is "cwd", and one useful variable is ${fileDirname}... Commented Mar 6, 2019 at 16:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.