Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is go not portable to all of those platforms?


No doubt it's potentially portable. Can I compile a GO only program and run on ios?


I did it, its trivial. The magic sauce is all in the use of the #cgo directive, which gives you a way of exporting Go to iOS code and vice versa. I ported IPFS (http://ipfs.io/) as a test, and it runs quite well on iOS:

https://github.com/seclorum/ios-go-ipfs/blob/master/ipfsios/...


Is see stuff like 'cgo' and 'import "C"'.

What's going on here?


This is the glue that the Go compiler needs to export its symbols in a way that they can be used from the C side of things in Objective-C, and vice versa. Think of it like a toll-free bridge [ * ] between the ObjC and Golang runtimes.

[ * - See https://en.wikipedia.org/wiki/Bridging_(programming) ]


You dont need to do any of the cgo stuff manually anymore with gomobile




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: