15

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
  • 12
    it's like running any binary file... make it executable chmod +x and run it ./binary
    – Nevermore
    May 30, 2017 at 13:21
  • Thanks a lot. So the problem was lack of Ubintu knowledge :) May 30, 2017 at 13:38

2 Answers 2

30

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
10

To avoid using ./ or any other path to the binary, you can copy the binary file to your /usr/local/bin/ path.

For example-

  1. Download a binary file that was compiled with Go, for example app
  2. Provide execution permission - chmod +x ~/Downloads/app
  3. Copy binary file to /usr/local/bin - cp ~/Downloads/app /usr/local/bin/app
  4. Execute the application from anywhere - app
1
  • 1
    Thanks, I installed some modules they were /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!) Jul 5, 2022 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.