drpmazn9021 2019-06-29 19:08
浏览 104
已采纳

无法在Visual Studio代码中调试Go

I have a folder, D:\Data\Git\go\src\demo containing one file, main.go. I have installed go1.12.6 windows/amd64. (I am running Windows 10) I am unable to debug the application - the debugger flashes on the screen then disappears ==> nothing happens ==> even though I have set a breakpoint, it does not break into the code for interactive step-through! I can run the app from the commandline ==> go run main.go (current directory is where main.go is located)

My launch.json looks like this:

{
    // 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": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {},
            "args": []
        }
    ]
}

Here is my app:

package main

import "fmt"

func main() {
    s := []int{2, 3, 5, 7, 11, 13}
    s = s[1:4]
    fmt.Println(s)
}

How do I get to debug in VS Code?

  • 写回答

1条回答 默认 最新

  • drqrdkfue521903877 2019-07-06 08:28
    关注

    Here is the answer:

    Ctrl+Shift+P ==> Open Launch.json ==> Save ==> Voila!

    (It works. I am now able to step through and debug a simple application with one main.go file in Visual Studio Code)

    Note that I have installed all of the dev tools (as per @owlwalks above), as well as dlv (see here: https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题