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.