Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top