Code Go locally on the iPad with iSH
I have been using iSH as Linux shell on my iPad. iSH emulates an x86 Alpine Linux OS on iOS and it generally works pretty well. I’ve used it regularly to SSH to my remote servers. iSH has had quite a few updates recently, some that would allow Golang to run and compile within iSH. So I figure that I should explore if I could code Go locally on the iPad and compile and run it inside iSH.
How to code Go locally on the iPad
The first thing to do is, of course, getting iSH installed on your iPad. To do that, just head over to https://ish.app/. As iSH is an emulation application, Apple would not allow this to be approved and published on the AppStore. Instead, the team at iSH has released this as a “beta” app that is “published” on TestFlight.
Click on the “Get iSH beta” button and you would be redirected to first download the TestFlight app if you don’t already have it on your iPad. TestFlight is where beta versions of applications are distributed for beta testers. Once you have TestFlight installed, you would then be able to accept and join as a “beta tester” for iSH.
If you are reading this, I am assuming that you are comfortable with Linux in general. The following apk install command will install all the necessary for you to run and build go code in iSH.
apk add --no-cache --virtual .build-deps bash gcc musl-dev openssl go
At this point, you’re ready to run and build go code on your iPad!
VIM? Perhaps a code editor for files in iSH?
You can of course pull your code from a git repository and just build and run the Go code on iSH. But since the whole point is to also code Go locally on the iPad, you will want to get a decent code editor on the iPad that can edit the your go code that resides in the iSH.
Koder supports opening and editing a file that is available on Files. And since iSH exposes the / volume to Files, this works quite seamlessly.
The earlier screenshot shows a simple Go code that makes a simple GET requests to the Postman Echo API that is edited and saved to a directory in iSH. The screenshot below shows the same file when you view it in iSH.
go build -o awesome program.go
Most of Go runs generally well in iSH. One thing to note is that iSH runs on a x86 emulation so its all 32-bit here. Here’s a view of the go env.
You may also get the “cannot find runtime/cgo” error sometimes. Even when the code compiles and runs well.
One last thing, the compilation time can take a while even for a simple code. So patience is required, and perhaps this is really more of a proof of concept than something that you can really use as a primary Go dev machine.
Regardless, here’s the video recording of the GET request to the Postman Echo API as per the earlier screenshots to see how it all works.