DEV Community

Just port a Golang game to Android

ntop on August 18, 2018

Months ago, @hajimehoshi wrote a post Go Packages we developed for our games, he use gomobile bind to port Go games to Android in his engine - ebi...
Collapse
 
krusenas profile image
Karolis

I actually explored similar strategy once and it was "okay" but it was far from a good android app.
Recently I have tried a bit different approach and was super happy with it:

  • App frontend written in Dart + Flutter. Dart seemed very familiar after Go and didn't even have to read language docs to actually write it. Flutter was also familiar after working with React/Vuejs (state management).
  • App backend (logic, storage) was written in Go as I am most comfortable writing GO.
  • Connecting frontend to backend via a JSON RPC, basically got a thin shim between the languages written in Java that I could write once and not modify ever. For example have a look at this: github.com/adieu/flutter_go.

Pros:

  • Flutter is a superior framework to anything I have ever seen for mobile.
  • Writing backend in Go seems safe and nice

Cons:

  • I would probably just go all-in and write the app fully in Dart but since I already had lots of code in Go that I could reuse for the app, it didn't make sense for me at that time.
Collapse
 
natoboram profile image
Nato Boram

Those are pretty critical issues you submitted - no SDK target, no back button, context not preserved after home button, stageDead not reported. I'm not sure I want to use GoMobile after reading these, that's like the basics to get an app to work. I wonder if there's actual people who use GoMobile. I would love to create Android apps in pure Go, but those issues are impossible to miss.

Collapse
 
ntoooop profile image
ntop

Yeah, I think there is no one really use gomobile build to build a workable APK, the author of ebiten engine @hajimehoshi use gomobile bind to work around those issues, he is the one I know that has published serval Golang games. GoMobile has hardcoded too much things. But those issues can be fixed easily, If anyone fixes the issues it'll be a good start!