在Visual Studio Code中使用Go扩展输入数据。

huangapple go评论75阅读模式
英文:

enter data in visual studio code with go extension

问题

我尝试为使用Go语言进行开发的Visual Studio Code进行设置。
我通过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: 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.<anonymous>
(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)

有什么解决方法吗?

英文:

i try to setup visual studio code for development with go language.
i install go extension by lukehoban, and dev tools from:
github.com/alecthomas/gometalinter and
github.com/derekparker/delve/cmd/dlv

ide doesn't show any errors.
when i run the following code:

package main

import &quot;fmt&quot;

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

    output := input * 2

    fmt.Println(output)    
}

i cannot enter any data on step fmt.Scanf(&quot;%f\n&quot;, &amp;input)

in debug console shows "debugger.go:413: nexting", but after enter any data process is stopped.

when i run the code without breakpoints i got:

> 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.<anonymous>
> (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)

any ideas how to fix it ?

答案1

得分: 1

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

您应该检查该扩展的官方GitHub存储库,看看是否已经报告了该问题。如果没有,您可以报告该问题。如果确实是扩展的问题,他们应该能够修复它。

如果最终发现这实际上是您配置扩展的方式有问题,他们应该能够提供更多关于修复的信息。

祝您好运!

英文:

Going based on the stack trace that you provided, I'm going to say that this is an issue with the Go extension.

You should check the extension's official GitHub repository to see if the issue has already been reported, and, if not you should go ahead and report it. If this is indeed an issue with the extension, they should hopefully be able to fix it.

If it turns out that this is actually an issue with the way you've configured the extension, they should be able to provide you more information about fixing it.

Best of luck!

huangapple
  • 本文由 发表于 2016年10月13日 23:47:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/40025553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定