tags:

views:

62

answers:

1

If my go program can be executed in different ways (cron, monit, etc..), what's the most reliable way to get the directory that contains the executable, during runtime?

In python, this would be the variable:

os.path.realpath(__file__)
+2  A: 

It's probably the same as in C, in other words, there isn't a portable fool-proof method. See http://stackoverflow.com/questions/933850/how-to-find-the-location-of-the-executable-in-c/933996#933996

ergosys