Code Go locally on the iPad with iSH

Share this:

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.

iSH app - Linux shell on iOS

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
Installing Go in iSH
Installing Go in iSH

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.

There are a lot of good code editors out there such as Coda Editor by Panic, Texastic Code Editor. I’m currently using a simple one called Koder Coder Editor.

Koder Code Editor
Koder Code Editor

Koder supports opening and editing a file that is available on Files. And since iSH exposes the / volume to Files, this works quite seamlessly.

Open files from Files in Koder
Open files from Files in Koder
Opening files in iSH in Koder
Opening files in iSH in Koder

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 code viewed 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.

Go environment variables in iSH
Go environment variables in iSH

You may also get the “cannot find runtime/cgo” error sometimes. Even when the code compiles and runs well.

Cannot find runtime/cgo error in iSH
Cannot find runtime/cgo error in iSH

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.

Coding Go natively on the iPad

Share this:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.