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 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备