2019-06-29 19:08
浏览 100

无法在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]

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)

    解决 无用
    打赏 举报

相关推荐 更多相似问题