英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论