Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to get the path of the executable during runtime?

Tags:

go

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__)
like image 332
marketer Avatar asked Oct 26 '22 15:10

marketer


1 Answers

It's probably the same as in C, in other words, there isn't a portable fool-proof method. See How do I find the location of the executable in C?

like image 82
ergosys Avatar answered Jan 02 '23 21:01

ergosys