Simple example to show how to get executable path for Go program.
Using:
os.Args[0]
filepath.Abs(os.Args[0])
runtime.Caller(0)
- github.com/kardianos/osext =>
osext.Executable
What you should test to compare behavior:
- running builded binary from different folder
go run
- running from symlinked folder/file
- running in cron
- running this program from other program/script
http://stackoverflow.com/questions/12090170/go-find-the-path-to-the-executable/