Find the path to the executable

后端 未结 3 688
半阙折子戏
半阙折子戏 2020-12-03 10:05

I compile a program with Go for various platforms and run it by calling a relative path or just by its name (if it is in the PATH variable).

Is it possible to find o

3条回答
  •  死守一世寂寞
    2020-12-03 10:33

    This is not go-specific (unless the go "standard library" contains some function to do it), and there is no portable solution. For solutions on some common platforms, see e.g. How do I find the location of the executable in C? or Finding current executable's path without /proc/self/exe .

提交回复
热议问题