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.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!