Every time I am running Go applications on MacOs with this command:
go run main.go
I get this pop up message:
Do you want the application "main" to accept incoming network connections?
I added Go
and all main
executable files to Firewall Exceptions but I am still getting this pop ups. I am running out of ideas. Please can anyone help me to get rid of those pop ups? At this point I have no idea if the problem is related to Golang or MacOs.
Best Answer
This is normal behaviour.
Each time you run
go run main.go
a new executable file is being created. This executable file is unique and unrecognised by macOS's security checks. Thus macOS asks, every time, for you to confirm if the new executable can have network access.Build and Sign
To avoid the warning, you need to build the executable file once and codesign it. You can build the executable file using the command:
The resulting executable called
mycmd
can be run using:To ad-hoc codesign this executable use:
This will cause macOS to trust this build of
mycmd
on your Mac. The first time it is run, you will be asked for network access. Subsequent runs will not require network checks.