0

How do you create a Golang executable that doesn't open a terminal window on OSX?

There's a similar question here for Windows. How do I create an executable from Golang that doesn't open a command (cmd) window when run?

Community
  • 1
  • 1
Shannon Matthews
  • 9,649
  • 7
  • 44
  • 75
  • I would believe that what matters is how do you start that executable (since MacOSX is a Unix or POSIX system). Very probably, if you start it as a `cron` job, it wont need any terminal. And if you start it on the command line, in an existing terminal, it probably won't open a new terminal window. – Basile Starynkevitch Aug 20 '15 at 05:50
  • @BasileStarynkevitch What about when double clicking the executable in Finder? Is it supposed to open a Terminal window then? – Shannon Matthews Aug 20 '15 at 05:52
  • See also [this](http://stackoverflow.com/q/10067295/841108) – Basile Starynkevitch Aug 20 '15 at 05:53
  • Would running as a daemon be suitable if the application has a GUI built with Electron? – Shannon Matthews Aug 20 '15 at 05:56
  • I have no idea (since I never coded for MacOSX). On POSIX systems, programs are started by running the [execve](http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html) function -it is often a [syscall](https://en.wikipedia.org/wiki/System_call)-, and there is no reason for it to start a window. The Finder is just a graphical user interface, you could avoid it. – Basile Starynkevitch Aug 20 '15 at 05:56
  • I don't think avoiding finder is the answer for me. I'm building an application for the public, so it really needs to behave like a regular Mac OSX application. – Shannon Matthews Aug 20 '15 at 05:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/87443/discussion-between-shannon-and-basile-starynkevitch). – Shannon Matthews Aug 20 '15 at 05:59
  • http://stackoverflow.com/a/23870490/395461 – Shannon Matthews Aug 21 '15 at 11:10

1 Answers1

3

Probably, you just need to pack your executable in application bundle. It's just a directory with .app extension where executable, resources and configs (plist-files) are stored.

You can read all specs at developer.apple.com. Also you can open bundles with your existing apps and look what's inside.

alex vasi
  • 5,304
  • 28
  • 31