我有一个 Go API,我正在尝试测试,并且我已经安装了反射。它启动并运行得很好,但每次我保存项目时,它都会创建应用程序的新实例。它将提示我的系统请求权限:
Do you want the application “go-api” to accept incoming network connections?
Clicking Deny may limit the application’s behavior.
This setting can be changed in the Firewall pane of Security & Privacy preferences.
非常感谢任何有关如何排除故障的帮助,甚至一些指导,因为我还没有看到有关此错误的任何信息。
当我检查 Mac 的隐私和安全设置时,我可以看到防火墙允许 go-api 实例以及许多其他 go-api 实例。
当我在查找器中显示这些应用程序时,我可以看到 Go 正在为程序的每个实例实例化单独的构建文件,并创建一个 Unix 可执行文件作为应用程序。
在我同事的设备上安装了同一 API 的 Go 和 reflex,此行为不存在。我不认为它与反射配置或 API 相关,因为它们的配置与我的完全相同,但没有表现出相同的行为。
我认为这可能与我的 .bash_profile 或其他内容有关:
# Setting PATH for Go
export GOPATH="$HOME/go"
PATH="$GOPATH/bin:$PATH"
export GOOGLE_APPLICATION_CREDENTIALS=/Users/me/Documents/path/to/go-api
export GO_ENV=dev
最佳答案
更新:我找到了一个解决方案,尽管并不令人满意。根据苹果公司的说法:
If you run an unsigned app that is not listed in the firewall list, a dialog appears with options to Allow or Deny connections for the app. If you choose Allow, OS X signs the application and automatically adds it to the firewall list. If you choose Deny, OS X adds it to the list but denies incoming connections intended for this app. -- https://support.apple.com/en-us/HT201642
所以,我关闭了防火墙,因为我还没有找到一种方法来挑选我的应用程序并允许它,同时仍然保持防火墙运行。
关于macos - 使用反射运行 Go 服务器时 Mac 反复要求接受网络连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58661434/