dongqiao8421 2014-04-22 21:05
浏览 7
已采纳

在本地无业游民的机器上运行Go脚本

I want to run Go scripts with Vagrant. When I do vagrant up, and run the command 'go version' I do not see any Go installed and am told that

The program 'go' is currently not installed.  You can install it by typing:
sudo apt-get install golang-go

` So I did install it and now it's running with simple scripts like fmt.Println()

Then my question is...

I have a repository with a lot of code in Go. And need to run this in Virtual Machine with Vagrant.

Then what would be the best way to run the scripts that were worked on outside of Vagrant VM because when I do vagrant up I do not see anything so I had to install Go.

  • 写回答

1条回答 默认 最新

  • dtvp3625 2014-04-22 21:14
    关注

    You generally don't want to deploy via source and go run. The run command is mostly just a connivence wrapper that builds and executes your binary in one step. There's a lot that it can't do. Compile your code, and run the binary.

    If the deployment target is a different os/architecture, there's nothing wrong with building the executable in the VM, just make sure it's has Go. You can also cross-compile you code if you don't have any dependency on cgo, which may be easier.

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

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)