calmdocs/SwiftPollManager allows you to run a golang binary embedded in a native macOS SwiftUI app. The golang binary and SwiftUI app communicate via http long polling. I hope that you find it useful.
Websockets on macOS is flakey
A while ago, I released calmdocs/SwiftStreamManager, which does the same thing, but communicates via websockets.
While calmdocs/SwiftStreamManager works as advertised, if used on a macOS laptop that is often woken and put to sleep, after a long period of time the Swift websocket connection may fail, requiring an automatic restart of the golang binary. This is an issue with the underlying macOS Swift websockets library. Please consider using calmdocs/SwiftPollManager instead which communicates via http long polling.
Messages between the golang binary and SwiftUI app should be encrypted …
Almost all of the feedback that I recived in relation to calmdocs/SwiftStreamManager was in relation to whether encrypting the messages sent between the golang binary and SwiftUI app is necessary. I think that it is. macOS does not allow you to use https (i.e. encrypted) connections without significant complexity. However, connecting the SwiftUI and golang apps via http is relatively simple.
calmdocs/SwiftPollManager allows the creation of a Diffie–Hellman Key Exchange (DHKE) connection between the SwiftUI app and golang app using the calmdocs/SwiftKeyExchange swift library and calmdocs/keyexchange go library. The SwiftUI app sends its public key as an argumant to the golang app, and the golang app then sends its public key to stdOut as a PEM message for the SwiftUI app to read.
… but encryption is optional
calmdocs/SwiftPollManager also contains simple implementation instuctions If you want to use this library without encypting or if you want to use your own encryption.