debugging - 使用 go 扩展在 visual studio code 中输入数据

标签 debugging go visual-studio-code

我尝试设置 visual studio 代码以使用 go 语言进行开发。 我安装了 lukehoban 的 go extension,以及来自以下的开发工具: github.com/alecthomas/gometalinter 和 github.com/derekparker/delve/cmd/dlv

ide 没有显示任何错误。 当我运行以下代码时:

package main

import "fmt"

func main() {
    fmt.Print("Enter a number: ")
    var input float64
    fmt.Scanf("%f\n", &input)

    output := input * 2

    fmt.Println(output)    
}

我无法在步骤 fmt.Scanf("%f\n", &input) 上输入任何数据

在调试控制台中显示“debugger.go:413: nexting”,但在输入后任何数据进程都停止了。

当我在没有断点的情况下运行代码时,我得到:

TypeError: Cannot read property 'currentGoroutine' of null\n at GoDebugSession.evaluateRequest (C:\Users\a.holikau.vscode\extensions\lukehoban.Go-0.6.44\out\src\debugAdapter\goDebug.js:595:45)\n at GoDebugSession.DebugSession.dispatchRequest (C:\Users\a.holikau.vscode\extensions\lukehoban.Go-0.6.44\node_modules\vscode-debugadapter\lib\debugSession.js:421:22)\n at GoDebugSession.ProtocolServer._handleData (C:\Users\a.holikau.vscode\extensions\lukehoban.Go-0.6.44\node_modules\vscode-debugadapter\lib\protocol.js:104:38)\n at Socket. (C:\Users\a.holikau.vscode\extensions\lukehoban.Go-0.6.44\node_modules\vscode-debugadapter\lib\protocol.js:24:60)\n at emitOne (events.js:96:13)\n at Socket.emit (events.js:188:7)\n
at readableAddChunk (_stream_readable.js:176:18)\n at Socket.Readable.push (_stream_readable.js:134:10)\n at Pipe.onread (net.js:543:20)

有什么办法可以解决吗?

最佳答案

根据您提供的堆栈跟踪,我会说这是 Go 扩展的问题。

您应该检查扩展程序的 official GitHub repository查看问题是否已被报告,如果没有,您应该继续 report it .如果这确实是扩展程序的问题,他们应该能够修复它。

如果事实证明这实际上是您配置扩展程序的方式存在问题,他们应该能够为您提供有关修复它的更多信息。

祝你好运!

关于debugging - 使用 go 扩展在 visual studio code 中输入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40025553/

相关文章:

go - golang中定期刷新 channel

python - vscode python linux : how to automatically open terminal in right venv?

angular - 'zsh : command not found: ng' in Visual Studio Code's integrated terminal on Mac Catalina

c++ - 崩溃时如何为我的进程创建小型转储?

java - onClick takeScreenShot 导致暂停

go - 使用 GORM 从 Postgresql 检索表名称

javascript - 如何整合Golang后端和Javascript(three.js)前端?

c# - 如何在 Visual Studio 中测试运行需要 SSL 的 ASP.NET MVC 网站?

ios - Xcode 不会越过崩溃

visual-studio-code - VSC 无法监视这个大工作区中的文件更改,很奇怪