使用go扩展名在visual studio代码中输入数据

时间:2016-10-13 15:47:56

标签: debugging go visual-studio-code

我尝试使用go语言设置visual studio代码以进行开发。 我通过lukehoban安装go扩展,并从以下开发工具: 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:无法读取null \ n的属性'currentGoroutine'   GoDebugSession.evaluateRequest   (C:\ Users \用户a.holikau.vscode \扩展\ lukehoban.Go-0.6.44 \出的\ src \ debugAdapter \ goDebug.js:595:45)\ n   在GoDebugSession.DebugSession.dispatchRequest   (C:\ Users \ a.holikau.vscode \ extensions \ lukehoban.Go-0.6.44 \ node_modules \ vscode-debugadapter \ lib \ debugSession.js:421:22)\ n在GoDebugSession.ProtocolServer._handleData   (C:\ Users \用户a.holikau.vscode \扩展\ lukehoban.Go-0.6.44 \ node_modules \ vscode-debugadapter \ lib中\ protocol.js:104:38)\ n   在Socket。   (C:\ Users \用户a.holikau.vscode \扩展\ lukehoban.Go-0.6.44 \ node_modules \ vscode-debugadapter \ lib中\ protocol.js:24:60)\ n   在emitOne(events.js:96:13)\ n在Socket.emit(events.js:188:7)\ n
  在readableAddChunk(_stream_readable.js:176:18)\ n at   Pipe.onread中的Socket.Readable.push(_ stream_readable.js:134:10)\ n   (net.js:543:20)

任何想法如何修复它?

1 个答案:

答案 0 :(得分:1)

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

您应该检查扩展程序的official GitHub repository以查看问题是否已经报告过,如果没有,您应该继续report it。如果这确实是扩展的问题,那么他们应该能够解决它。

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

祝你好运!