dtu36380 2016-06-28 15:15
浏览 582

在Visual Studio Code中运行Golang

Can anyone tell me how can I run and use debugger in Visual Studio for a simple go program in Windows step by step?

I took a reference from this page:

https://marketplace.visualstudio.com/items?itemName=lukehoban.Go

But I was not able to run the code. My current GOPATH is C:\dev\go. Please let me know if any other details are required.

  • 写回答

3条回答

  • dongmeiyi2266 2016-06-28 15:58
    关注

    First of all, debuggers are not part of Go. C#, F# and other managed languages under the Microsoft stack have debuggers as that's part of the .NET stack.

    Second, Visual Studio Code != Visual Studio. VS Code is a light(er) weight IDE that is geared towards extensibility to support a wide range of languages by creating runners. But that's the thing: someone else needs to write the runners and hopefully they created a seamless experience with a Debugger (if available). This is why you have multiple versions of language runners.

    In other words: if you want a VSCode-compatible Debugger+Runner for X language, read up on X language about how to debug it.

    Go is no exception. You must read the language spec, and specifically I recommend Effective Go as it explains why you don't need a Debugger.

    --

    Now with all of that said, the community has come together and created somewhat of a debugger for GoLang. It is called Delve.

    Learning how to install it for VS Code is beyond this post. I recommend finding a VSCode package that supports Go coding with Delve (there is at least one out there, as I have used it).

    Opinion: it's an Ok experience in VSCode to debug Go. I've experimented with it. While visually pleasing, I went back to Atom for it's large package support of many other Go utilities and Linters - most of which is missing in VSCode (and some packages didn't allow me to modify the config to exclude certain Go workflows).

    EDIT 2018: After a few years, VSCode has matured nicely! I've since switched 100% to VSCode as my primary editor.

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作