VScode调试模式找不到我的config.json文件。

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

VScode debug mode can't find my config.json file

问题

我正在尝试在VScode上调试一个Go应用程序,但是我的config.json文件找不到。我得到了一个Error occurred while reading config. panic: open config.json: The system cannot find the file specified的错误。

这是我的launch.json文件,我将工作区路径设置为src,这是我存放Go文件和主包的位置。

    "configurations": [
        
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceRoot}\\src"
        }
    ]
}```

config.go文件的级别比src文件夹高一级。我已经附上了我的工作区结构的截图。我做错了什么?

<details>
<summary>英文:</summary>

I am trying to debug a go application on VScode, but my config.json can&#39;t be found. I am getting a ```Error occurred while reading config.
panic: open config.json: The system cannot find the file specified``` error.

This is my launch.json file and I have my workspace path set to the src, which is where I have my go files and main package. 



```  &quot;version&quot;: &quot;0.2.0&quot;,
    &quot;configurations&quot;: [
        
        {
            &quot;name&quot;: &quot;Launch Package&quot;,
            &quot;type&quot;: &quot;go&quot;,
            &quot;request&quot;: &quot;launch&quot;,
            &quot;mode&quot;: &quot;auto&quot;,
            &quot;program&quot;: &quot;${workspaceRoot}\\src&quot;
        }
    ]
}```

The config.go file is a level higher than the src folder. I have attached a screenshot of my workspace structure. What am I doing wrong?



 [![screenshot of my workspace structure][1]][1] 


  [1]: https://i.stack.imgur.com/mz4KL.png

</details>


# 答案1
**得分**: 0

尝试使用以下配置:

"configurations": [
{
"name": "启动包",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]


<details>
<summary>英文:</summary>

Try this config

"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]

huangapple
  • 本文由 发表于 2022年3月3日 23:21:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/71339580.html
匿名

发表评论

匿名网友

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

确定