I'm a newbie of golang :) learning.......
Currently I got a problem: how to ge the path of the executable file
for the current process. E.G.:
I wrote a native linux executable program with go, put it under /
home/axe/bin/testgo. /home/axe/bin is in my $PATH.
Then I run it under /home/axe/Desktop/ and want it to print out a
message: I come from /home/axe/bin/.
The message string is got in runtime, not hardcoded in source code :)
Currently I got a problem: how to ge the path of the executable file
for the current process. E.G.:
I wrote a native linux executable program with go, put it under /
home/axe/bin/testgo. /home/axe/bin is in my $PATH.
Then I run it under /home/axe/Desktop/ and want it to print out a
message: I come from /home/axe/bin/.
I think filepath.Abs(os.Args[0]) should provide that info.
This will not work if the command was launched not relative to the current directory (ie, it was found in $PATH).
On the Sun-2 and Sun-3, ex/vi looked at argv[0] to decide if it should be ex or vi.
On Tue, Dec 20, 2011 at 8:27 AM, Paul Borman <bor...@google.com> wrote:
and was even used as a flag to programs in some cases
--
> On the Sun-2 and Sun-3, ex/vi looked at argv[0] to decide if it should be ex or vi.
And System V used it to decide whether to be cp, ln, or mv. I opined at the time that there could be just one huge a.out for all the Unix commands. They didn't bite.
-rob