douhong6187 2018-03-28 14:26
浏览 82
已采纳

Windows 10 golang安装程序。 错误,不在环境中

I am running into issues setting up go for the first time on a Windows 10 machine.

I followed the instructions from the install. https://golang.org/doc/install?download=go1.10.windows-386.msi

When I CD to my project E:\goProjects\goWebApp\src and run go build, I receive the following error.

C:\windows\system32>go version
Not in an environment
C:\Users\MyUser~1\AppData\Local\Temp\go_there.bat' is not recognized as an internal or external command,
    operable program or batch file.

My system variables are as follows:

  • GOPATH=E:\goProjects\goWebApp
  • GOROOT=C:\Go
  • PATH=C:\Go\bin

If I run go version from C:\Go\bin everything works fine. Running go command from anywhere outside of this directory does not work. I have also tried restarting my cmd prompt and restarting my computer. Still no luck. Has anyone else ran into this issue? Or know what I might have done wrong?

enter image description here

  • 写回答

1条回答 默认 最新

  • dpyln64620 2018-03-28 15:57
    关注

    Turns out I had two go locations in my PATH (sort of). When I ran the command where go from command prompt two paths were returned.

    Something like this..

    C:\tools\devTools\bin
    C:\Go\bin\go.exe
    

    There apparently was a bat file in devTools\bin called go.bat. This was unrelated to golang itself, just coincidental naming unfortunately.This was executing instead of the go binary, which in return was throwing the random error with the Not in an environment message.

    To fix the issue I just removed the devTools path from my PATH variable for now.

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

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么