golang:即使更改了代码,go run仍然始终运行旧代码。

huangapple go评论68阅读模式
英文:

golang: go run is always running old code even after changes

问题

我在使用golang时遇到了一个奇怪的问题。我运行了以下命令(像往常一样):

go run main.go

然后我对代码进行了一些更改,然后再次运行:

go run main.go

但是执行的代码是旧版本的代码。所以我尝试了一些方法:

  • 重新启动计算机
  • 删除临时文件夹中的所有临时二进制文件
  • 重新安装go
  • 删除并重新放置我的代码
  • 删除一些文件

但它仍然运行旧版本的代码。我没有找到解决这个问题的方法,而且关于这个问题的帖子也没有给出解决方案(这里这里)。

关于我的配置,如下所示:

  • 运行Raspbian(已更新)的Raspberry Pi
  • Go版本1.8.1

希望你能帮助我!提前感谢!

最好的问候,

英文:

I have a weird issue with golang. I run the command (like everytime):

go run main.go

Then I made some change into my code and then I run again:

go run main.go

But the executed code is the old version of the code. So I tried some stuff:

  • Reboot the computer
  • Delete all the temporary binaries into temp folder
  • Reinstall go
  • Delete and put back my code
  • Remove some file

But it is still running my old version of the code. I didn't find solution about this issue, and the few post about it doesn't give a solution (here and here).

About my configuration it is the following:

  • Raspberry pi running Raspbian (updated)
  • Go version 1.8.1

I hope you can help me !
Thank in advance!

Best regards,

答案1

得分: 4

好的!问题出在导入部分。在代码中,一些导入调用了旧版本的代码。

英文:

Okay!
The problem come from the imports. In the code some imports was calling old version of the code.

答案2

得分: 1

我认为你的GOPATH指向了一个错误的文件夹。请运行go env命令,确保它指向正确的目录。如果没有设置,请将其设置为存放Go文件的位置。请注意,通常情况下,go run命令不需要指定文件,但如果你需要指定文件,你必须列出你的应用程序中main.go依赖的所有文件。

请参考这里

英文:

I think your GOPATH is pointing to a wrong folder. Please, run go env to make sure that it is pointing to the right directory. If not set it to location where go files are. Please, take into account that go run usually does not need a file specification and if you do you have to list defacto all files of your app that main.go depends upon.

Have a look ``here

huangapple
  • 本文由 发表于 2017年7月25日 23:02:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/45307076.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定