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

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

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文件和主包的位置。

  1. "configurations": [
  2. {
  3. "name": "Launch Package",
  4. "type": "go",
  5. "request": "launch",
  6. "mode": "auto",
  7. "program": "${workspaceRoot}\\src"
  8. }
  9. ]
  10. }```
  11. config.go文件的级别比src文件夹高一级。我已经附上了我的工作区结构的截图。我做错了什么?
  12. <details>
  13. <summary>英文:</summary>
  14. 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.
  15. panic: open config.json: The system cannot find the file specified``` error.
  16. 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.
  17. ``` &quot;version&quot;: &quot;0.2.0&quot;,
  18. &quot;configurations&quot;: [
  19. {
  20. &quot;name&quot;: &quot;Launch Package&quot;,
  21. &quot;type&quot;: &quot;go&quot;,
  22. &quot;request&quot;: &quot;launch&quot;,
  23. &quot;mode&quot;: &quot;auto&quot;,
  24. &quot;program&quot;: &quot;${workspaceRoot}\\src&quot;
  25. }
  26. ]
  27. }```
  28. 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?
  29. [![screenshot of my workspace structure][1]][1]
  30. [1]: https://i.stack.imgur.com/mz4KL.png
  31. </details>
  32. # 答案1
  33. **得分**: 0
  34. 尝试使用以下配置:

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

  1. <details>
  2. <summary>英文:</summary>
  3. 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:

确定