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.

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

报告相同问题?