我正在开发 https://github.com/NorseGaud/go-daemon,我无法在子进程内运行 http GET 调用。我对 golang 和 os.Process 还不够了解。
我使用的是 macOS。
当我运行“go run Examples/cmd/gd-signal-handling/signal-handling.go”时,这只是在子进程中执行一个简单的
httpClient.Do
,我看到:
2024/04/05 17:45:33 - - - - - - - - - - - - - - -
2024/04/05 17:45:33 daemon started
1
2024/04/05 17:45:34 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
但是,如果我在主函数中运行相同的
httpClient.Do
,它就会起作用。
然后我使用“go run Examples/cmd/gd-signal-handling/signal-handling.go -s quit”退出进程。
熟悉 golang 和流程的人可以向我解释为什么这是不可能的吗?
好吧,解决办法就是使用绝对路径运行。 @nimdrak 是对的,https://github.com/golang/go/issues/61000 就是这里的问题。