'Golang on macOS - how to pass arguments to .app executable

I'm building an app to display files paths on macOS in a window, it's working correctly when I compile it and run it from the CLI:

❯ go build main.go
❯ ./main "test1" "test2"

The app opens the window and correctly shows the paths of the files.

However, after running make and turning it into an .app executable, I obviously can't pass CLI arguments anymore.

If I try to drag and drop a picture, or any type of file over the app, nothing happens, and if I select a file and do right-clic + open with... {my app}, I get an error:

The document “not_default.gif” could not be opened. helloworld cannot open files in the “GIF image” format.

Do you have any idea of a library, documentation or code I can use to pass file paths to the .app executable, or what's causing the error when I try to open the files with my .app ?

go


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source