Is it possible to write macOS/Cocoa applications in Google Go?
Is there a Go-Obj-C bridge? (it seems to me that Obj-C dynamism would be a great fit for Golang's interfaces)
Can I at least link the two together and make them talk to each other via plain-old C functions?
CGo is what enables you to call C code.
See the CGo doc and the informative, official blog post on it.
There does not seem to be cocoa bindings/libraries yet, but you may want to check out the GTK package for reference.
Right now there doesn't seem to be a package for binding Cocoa to Go. Cocoa is written in Objective-C which is a superset of C. Objective-C messages are (or at least used to be, not sure about the modern compilers) translated to C function calls by the compiler, to something like this:
objc_msgSend(object, sel_getUid("foo:bar:err:"), var, var2, errVar);
So it's definitely possible to use Cocoa from Go.
If you run in to a problem where you find you would like to use Cocoa in a Go app, IMHO take a step back and think about the problem you're trying to solve. Cocoa makes heavy use of named parameters and methods can have quite long signatures. This works well in Objective-C but I doubt the code would look as good in Go. On the other hand, Go solves another set of problems. Maybe writing a library (application logic) in Go and GUI code in Objective-C/Cocoa would do the trick?
TL;DR: How about writing model in Go and GUI code in Objective-C?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With