使用应用程序打开:如何在go中检测文件名

I have created a go application on my mac that reads/writes from files *.myext. The executable was packed into an a Bundle called "MyApp".

I can start MyApp and then read/write *.myext files, that works.

My question is: how to detect the filename if I am opening e.g. test.myext by Open With > MyApp (usually right mouse button)?

I have tried to read the file name from os.Args, but the file name is not in there.

Is there a way?

Thank you for your help!

Leo

Looks like a program started via "Open With" does not receive the name of the file it has been invoked on but rather has to obtain it using "Apple events" as described in the accepted answer here.

I am thereby afraid currently the only way to solve the problem would be to use cgo; may be along these lines.