I read a lot about "You can run a Go program from binaries without even having Go installed on your machine", etc. How exactly should I execute the app?
In my case I have a console application which sends emails if a certain event occurs. There also is a .toml file for configuring it. How should I run the app on a PC which does not have Go installed and is running Ubuntu 14.04.1 (Trusty Tahr) 64-bit OS?
2 Answers 2
The application should be executed just like any other binary can be executed in the given OS. In your case, running on Ubuntu, you must first compile the application for that particular architecture:
env GOOS=linux GOARCH=arm go build
Then you can modify the permissions of the binary to be executable:
chmod +x my-app
And simply execute it:
./my-app
Comments
To avoid using ./ or any other path to the binary, you can copy the binary file to your /usr/local/bin/ path.
For example-
- Download a binary file that was compiled with Go, for example
app - Provide execution permission -
chmod +x ~/Downloads/app - Copy binary file to
/usr/local/bin-cp ~/Downloads/app /usr/local/bin/app - Execute the application from anywhere -
app
1 Comment
/Users/user/go/bin directory, each time I needed to move to that directory for execution, I have forgotten about coping binary to /usr/local/bin your answer remained me, thanks for your help!)
chmod +xand run it./binary