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

发布于 2025-01-11 09:20:11 字数 660 浏览 0 评论 0原文

我正在尝试在 VScode 上调试 go 应用程序,但找不到我的 config.json。我在读取配置时遇到错误。恐慌:打开config.json:系统找不到指定的文件错误。

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

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

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.sstatic.net/mz4KL.png

I am trying to debug a go application on VScode, but my config.json can'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.

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

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.sstatic.net/mz4KL.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁拥 2025-01-18 09:20:11

试试这个配置

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

Try this config

"configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}"
        }
    ]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文