You might be able to use os.Args[0] to check whether or not that is an absolut or relativ path or just the executable name. If its an absolute path, just use it, if it is relative, then use filepath.Rel(os.Getwd(), os.Args[0]) or if it is just the name, then you’ll need to search all entries in the PATH environment variable if there is an executable file with the name learnt from os.Args[0].
But why do you actually need that path? A good executable doesn’t care about where it lives.
This allow me to execute my program from everywhere. Also i use filepath.Join(path, filename) to access safe other files from the application subfolders.
LE: I guess is not a good idea to use relative paths . I think about running your application from crontab where absolute path counts.