dongzhijing8202 2017-08-03 10:04
浏览 41
已采纳

Golang命令不起作用

I just started learning golang.I have very little knowledge.

I have clicked on the link below and uploaded the package indicated by the arrow in the picture to my computer

https://golang.org/dl/

enter image description here

After that

I created a folder called golang on my desktop as shown in the picture below.

enter image description here

I open this folder on visual studio code and i have downloaded below addition.

enter image description here

Finally I wrote the following code and after I ran the cod "go run main.go". But the code I wrote did not work.

enter image description here

Question: It came to me a little confused golang.What do i have to do to run this code what am i doing wrong?

Thanks

  • 写回答

1条回答 默认 最新

  • dry18813 2017-08-03 10:33
    关注

    It's obviously not on the path. It's a bit weird as I believe Windows installer adds it properly. You can fix it though, by going to Control Panel -> System -> Advanced (Tab) -> Environment Variables. (Actual names will likely differ in your version of windows, but should be recognizably close. In worst case, search Setting environment variables for your version of windows in google.). Then find PATH variable and add path to the go executable. You'll also need to have GOROOT variable set as well.

    For example, I have Go installed in C:\Go folder. So, I have GOROOT variable set as C:\Go and C:\Go\bin added to PATH variable. You can have them as either User or System variables. User ones will be visible only to you, while System ones will be for everyone. That's the only difference.

    Keep in mind though that it will only affect programs started after you have updated environment variables settings. So, you'll have to restart VS Code for it to take effect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分