SlideShare a Scribd company logo
1 of 65
Download to read offline
HelloMobile.go
SeongJae Park <sj38.park@gmail.com>
This work by SeongJae Park is licensed under the Creative
Commons Attribution-ShareAlike 3.0 Unported License. To
view a copy of this license, visit http://creativecommons.
org/licenses/by-sa/3.0/.
This slides were presented during
GopherCon Korea 2015
(https://plus.google.com/u/0/events/c4b79ocq4k9ac11bpb5b2govkes)
Nice To Meet You
SeongJae Park
sj38.park@gmail.com
golang newbie programmer
Warning
● This speech could be useless for you
○ The speaker is doing this just for fun
https://github.com/golang/mobile/raw/master/doc/caution.png
Warning
● This speech could be useless for you
○ The speaker is doing this just for fun
● Don’t try this at office carelessly
○ It’s an experiment yet
https://github.com/golang/mobile/raw/master/doc/caution.png
Java is Dangerous, Now
● Oracle may take Java away from Android
● Swift is open source now, but...
● We need alternatives
http://img.talkandroid.com/uploads/2011/10/OracleGoogle.jpg
golang: Programming Language
● For simple, reliable, and efficient software.
http://blog.golang.org/5years/gophers5th.jpg
golang: Programming Language
● For simple, reliable, and efficient software.
● Could it be used for simple, reliable, efficient,
and free mobile application?
http://blog.golang.org/5years/gophers5th.jpg
Golang on Mobile
● Golang supports Android from v1.4
● Golang supports iOS from v1.5
○ Though it’s still in experimental stage, there were
many improvements especially in tools
● https://github.com/golang/mobile
○ Repo of packages and tools for Go on Mobile
Goal of This Speak
● Showing how we can use golang on Mobile
○ Focus on Android, rather than iOS
(Speaker has no iPhone…)
○ By exploring example code
Goal of This Speak
● Showing how we can use golang on Mobile
○ Focus on Android, rather than iOS
(Speaker has no iPhone…)
○ By exploring example code
● We will explore code based on go1.4, go1.5
○ Code based on go1.4 shows naked face of build
process
■ based on go1.4: https://github.com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f5725a5cbcd6b
■ based on go1.5: https://github.com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c555366d20
Pre-requisites
● Basic development environment(vim, git,
gcc, java, gradle, …)
http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
Pre-requisites
● Basic development environment(vim, git,
gcc, java, gradle, …)
● Android SDK & NDK
http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
Pre-requisites
● Basic development environment(vim, git,
gcc, java, gradle, …)
● Android SDK & NDK
● Golang 1.4 cross-compiled for GOOS=android
or higher versions
http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
Pure Golang Mobile App
NO JAVA!
Main Idea: NDK
● c / c++ only apk is available
using NativeActivity
○ Golang is a compiled language, too. Why not?
http://www.android.pk/images/android-ndk.jpg
Main Idea: NDK
● c / c++ only apk is available
using NativeActivity
○ Golang is a compiled language, too. Why not?
Plan is as below:
● Build golang program as .so file
○ ELF shared object
● Process events(draw, touch, …) via OpenGL
● Build NativeActivity apk using NDK / SDK
http://www.android.pk/images/android-ndk.jpg
Example Code
https://github.
com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f57
25a5cbcd6b/example/basic for 1.4 based
https://github.
com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c
555366d20/example/basic for 1.5 based
Example Code (1.4 based)
https://github.
com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f57
25a5cbcd6b/example/basic
$ tree
.
├── all.bash
├── all.bat
├── AndroidManifest.xml
├── build.xml
├── jni
│ └── Android.mk
├── main.go
├── make.bash
└── make.bat
1 directory, 8 files
main.go: Register Callbacks
Register callbacks from golang entrypoint
(After 1.5, programming model changed a little)
func main() {
app.Run(app.Callbacks{
Start: start,
Stop: stop,
Draw: draw,
Touch: touch,
})
}
(mobile/example/basic/main.go)
main.go: Use OpenGL
func draw() {
gl.ClearColor(1, 0, 0, 1)
...
green += 0.01
if green > 1 {
green = 0
}
gl.Uniform4f(color, 0, green, 0, 1)
...
debug.DrawFPS()
}
(mobile/example/basic/main.go)
NativeActivity
NativeActivity only application doesn’t need
JAVA
<application android:label="Basic" android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:label="Basic"
android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.lib_name" android:value="basic" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
(mobile/example/basic/AndroidManifest.xml)
NativeActivity
NativeActivity only application doesn’t need
JAVA
<application android:label="Basic" android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:label="Basic"
android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.lib_name" android:value="basic" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
(mobile/example/basic/AndroidManifest.xml)
NativeActivity
NativeActivity only application doesn’t need
JAVA
<application android:label="Basic" android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:label="Basic"
android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.lib_name" android:value="basic" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
(mobile/example/basic/AndroidManifest.xml)
Build Process
Build golang code into ELF shared object for
ARM
mkdir -p jni/armeabi
CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 
go build -ldflags="-shared" -o jni/armeabi/libbasic.so .
ndk-build NDK_DEBUG=1
ant debug
(mobile/example/basic/make.bash)
Build Process
Build golang code into ELF shared object for
ARM
NDK to add the so file
mkdir -p jni/armeabi
CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 
go build -ldflags="-shared" -o jni/armeabi/libbasic.so .
ndk-build NDK_DEBUG=1
ant debug
(mobile/example/basic/make.bash)
Build Process
Build golang code into ELF shared object for
ARM
NDK to add the so file
SDK to build apk file
mkdir -p jni/armeabi
CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 
go build -ldflags="-shared" -o jni/armeabi/libbasic.so .
ndk-build NDK_DEBUG=1
ant debug
(mobile/example/basic/make.bash)
Example Code (1.5 based)
https://github.
com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c
555366d20/example/basic
gomobile command do build
$ tree
.
└── main.go
0 directories, 1 file
Example Code (1.5 based)
https://github.
com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c
555366d20/example/basic
gomobile command do build
$ go get golang.org/x/mobile/cmd/gomobile
$ tree
.
└── main.go
0 directories, 1 file
Example Code (1.5 based)
https://github.
com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c
555366d20/example/basic
gomobile command do build
$ go get golang.org/x/mobile/cmd/gomobile
$ gomobile init # install ndk if needed
$ tree
.
└── main.go
0 directories, 1 file
Example Code (1.5 based)
https://github.
com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c
555366d20/example/basic
gomobile command do build
$ go get golang.org/x/mobile/cmd/gomobile
$ gomobile init # install ndk if needed
$ gomobile build -target=android golang.org/x/mobile/example/basic
$ tree
.
└── main.go
0 directories, 1 file
Pure Golang Android App
Pros: No more JAVA! Yay!!!
Cons: Should I learn OpenGL to show a cat?
Golang as a Library
Cooperate Java and Golang
Main Idea: Gives binding
Java and C language connected via JNI
Java
C
JNI
Main Idea: Gives binding
Java and C language connected via JNI
C language and Golang connected via cgo
Java
C GO
JNI
CGO
Main Idea: Gives binding
Java and C language connected via JNI
C language and Golang connected via cgo
ObjC(Objective C) is a super-set of C language
Java
C GO
JNI
CGO
ObjC
Main Idea: Gives binding
Java and C language connected via JNI
C language and Golang connected via cgo
ObjC(Objective C) is a super-set of C language
Golang supports Java/ObjC-Golang bind
(Uses Cgo internally)
Java
C GO
JNI
CGO
bind
ObjC
bind
Example Code (1.4 based)
https://github.
com/golang/mobile/tree/40f92
f7d9f9092072ea68570fd6f572
5a5cbcd6b/example/libhello
Example Code (1.4 based)
https://github.
com/golang/mobile/tree/40f92
f7d9f9092072ea68570fd6f572
5a5cbcd6b/example/libhello
$ tree
.
├── all.bash
├── all.bat
├── AndroidManifest.xml
├── build.xml
├── hi
│ ├── go_hi
│ │ └── go_hi.go
│ └── hi.go
├── main.go
├── make.bash
├── make.bat
├── README
└── src
├── com
│ └── example
│ └── hello
│ └── MainActivity.java
└── go
└── hi
└── Hi.java
8 directories, 12 files
Callee in Go
Golang code is implementing Hello() function
func Hello(name string) {
fmt.Printf("Hello, %s!n", name)
}
(mobile/example/libhello/hi/hi.go)
Caller in JAVA
Java code is calling Golang function, Hello()
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Go.init(getApplicationContext());
Hi.Hello("world");
}
(mobile/example/libhello/src/com/example/hello/MainActivity.java)
gobind
generate language bindings that make it
possible to call Go code and pass objects from
Java
$ go install golang.org/x/mobile/cmd/gobind
$ gobind -lang=go github.com/libhello/hi > hi/go_hi/go_hi.go # stub
$ gobind -lang=java github.com/libhello/hi > src/go/hi/Hi.java # proxy
gobind: Generated Proxy java Code
Provides wrapper function for golang calling
code
public static void Hello(String name) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeUTF16(name);
Seq.send(DESCRIPTOR, CALL_Hello, _in, _out);
}
private static final int CALL_Hello = 1;
private static final String DESCRIPTOR = "hi";
(mobile/example/libhello/src/go/hi/Hi.java)
gobind: Generated Stub go Code
Provides proxy and registering for the exported
function
func proxy_Hello(out, in *seq.Buffer) {
param_name := in.ReadUTF16()
hi.Hello(param_name)
}
func init() {
seq.Register("hi", 1, proxy_Hello)
}
(mobile/example/libhello/hi/go_hi/go_hi.go)
Example Code (1.5 based)
https://github.
com/golang/mobile/tree/25faf
494e186f45f8d9704fb53a6c6
c555366d20/example/bind
gomobile do binding
automatically
$ gomobile bind 
-target=android 
golang.org/x/mobile/example/bind/hello
$ tree
.
├── android
│ ├── README
├── ...
│ └── settings.gradle
├── hello
│ └── hello.go
└── ios
├── bind
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── main.m
│ ├── ViewController.h
│ └── ViewController.m
├── bind.xcodeproj
│ └── project.pbxproj
└── README
Golang as a Library
Pros: JAVA for UI, Golang for background
(Looks efficient enough)
Golang as a Library
Pros: JAVA for UI, Golang for background
(Looks efficient enough)
Cons: Binding supports only subset of Go types
Inter-Process
Communication
Philosophy of Unix
Main Idea: Android is a Linux
http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png
Android is a variant of Linux system with ARM
x86 Androids exist, though...
Main Idea: Android is a Linux
http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png
Android is a variant of Linux system with ARM
x86 Androids exist, though...
Go supports ARM & Linux Officially
with static-linking
Main Idea: Android is a Linux
http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png
Android is a variant of Linux system with ARM
x86 Androids exist, though...
Go supports ARM & Linux Officially
with static-linking
Remember the philosophy of Unix
Not tested for iOS
Example Code
https://github.com/sjp38/goOnAndroid
https://github.com/sjp38/goOnAndroidFA
Example Code
https://github.com/sjp38/goOnAndroid
https://github.com/sjp38/goOnAndroidFA
Were demonstrated as live-coding from
GDG Korea DevFair 2014 (http://devfair2014.
gdg.kr/) and
GDG Golang Seoul Meetup 2015 (https:
//developers.google.
com/events/5381849181323264/)
Golang Process on Android: Plan
1. Cross compile Go program as ARM / Linux
Golang Process on Android: Plan
1. Cross compile Go program as ARM / Linux
2. Include the binary in assets/ of Android app
Golang Process on Android: Plan
1. Cross compile Go program as ARM / Linux
2. Include the binary in assets/ of Android app
3. Copy the binary in private space of the app
Golang Process on Android: Plan
1. Cross compile Go program as ARM / Linux
2. Include the binary in assets/ of Android app
3. Copy the binary in private space of the app
4. Give execute permission to the binary
/data/data/com.example.goRunner/files # ls -al
-rwxrwxrwx u0_a55 u0_a55 4512840 2014-11-28 17:45 gobin
Golang Process on Android: Plan
1. Cross compile Go program as ARM / Linux
2. Include the binary in assets/ of Android app
3. Copy the binary in private space of the app
4. Give execute permission to the binary
5. Execute it
/data/data/com.example.goRunner/files # ls -al
-rwxrwxrwx u0_a55 u0_a55 4512840 2014-11-28 17:45 gobin
Go bin Loading
Load golang program from assets to private dir
private void copyGoBinary() {
String dstFile = getBaseContext().getFilesDir().getAbsolutePath() + "/verChecker.bin";
try {
InputStream is = getAssets().open("go.bin");
FileOutputStream fos = getBaseContext().openFileOutput(
"verChecker.bin", MODE_PRIVATE);
byte[] buf = new byte[8192];
int offset;
while ((offset = is.read(buf)) > 0) {
fos.write(buf, 0, offset);
}
Runtime.getRuntime().exec("chmod 0777 " + dstFile);
} catch (IOException e) { }
}
Execute Go process
Spawn new process for the program and
communicates using stdio
ProcessBuilder pb = new ProcessBuilder();
pb.command(goBinPath());
pb.redirectErrorStream(false);
goProcess = pb.start();
new CopyToAndroidLogThread("stderr",
goProcess.getErrorStream())
.start();
Inter Process Communication
Pros: Just normal unix way
Inter Process Communication
Pros: Just normal unix way
Golang team is using this for Camlistore
(https://github.com/camlistore/camlistore)
Inter Process Communication
Pros: Just normal unix way
Golang team is using this for Camlistore
(https://github.com/camlistore/camlistore)
Cons: Hacky, a little
x/mobile is comfortable enough, now
Not sure whether it works on iOS
Summary
● Go can run on Mobile
○ As a native application,
○ as a library,
○ or, as a process
● Though it’s an experiment yet, it’s fairly
comfortable

More Related Content

What's hot

SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
 

What's hot (20)

Fastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリーFastlane for Androidによる継続的デリバリー
Fastlane for Androidによる継続的デリバリー
 
Power of React Native
Power of React NativePower of React Native
Power of React Native
 
Intro. to Git and Github
Intro. to Git and GithubIntro. to Git and Github
Intro. to Git and Github
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
 
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
 
OpenMIC March-2012.phonegap
OpenMIC March-2012.phonegapOpenMIC March-2012.phonegap
OpenMIC March-2012.phonegap
 
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
如何透過 Golang 與 Heroku 來一鍵部署 臉書機器人與 Line Bot
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
 
All a flutter about Flutter.io
All a flutter about Flutter.ioAll a flutter about Flutter.io
All a flutter about Flutter.io
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
Mobile Development with Ionic, React Native, and JHipster - AllTheTalks 2020
 
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
iThome Chatbot Day: 透過 Golang 無痛建置機器學習聊天機器人
 
Going Native With React
Going Native With ReactGoing Native With React
Going Native With React
 
Tips & Tricks for Maven Tycho
Tips & Tricks for Maven TychoTips & Tricks for Maven Tycho
Tips & Tricks for Maven Tycho
 
Jedi knight
Jedi knightJedi knight
Jedi knight
 
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for ModulesUnderstanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
Understanding Pseudo-Versions Moving to Go 1.13 What is in Go 1.14+ for Modules
 
Cross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React NativeCross-Platform App Development with Flutter, Xamarin, React Native
Cross-Platform App Development with Flutter, Xamarin, React Native
 
Geek git
Geek gitGeek git
Geek git
 
Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016
 

Similar to Develop Android/iOS app using golang

Similar to Develop Android/iOS app using golang (20)

Mobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse BindingMobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse Binding
 
Porting golang development environment developed with golang
Porting golang development environment developed with golangPorting golang development environment developed with golang
Porting golang development environment developed with golang
 
Pwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreakPwning mobile apps without root or jailbreak
Pwning mobile apps without root or jailbreak
 
Boquet manager
Boquet managerBoquet manager
Boquet manager
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
PhoneGap
PhoneGapPhoneGap
PhoneGap
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 
A Noob’S Guide To Android Application Development
A Noob’S Guide To Android Application DevelopmentA Noob’S Guide To Android Application Development
A Noob’S Guide To Android Application Development
 
Head first android apps dev tools
Head first android apps dev toolsHead first android apps dev tools
Head first android apps dev tools
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Web applications support on AGL
Web applications support on AGLWeb applications support on AGL
Web applications support on AGL
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Jump into React-Native (Class 6)
Jump into React-Native  (Class 6)Jump into React-Native  (Class 6)
Jump into React-Native (Class 6)
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
React django
React djangoReact django
React django
 
Android Made Simple
Android Made SimpleAndroid Made Simple
Android Made Simple
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 

More from SeongJae Park

Deep dark side of git - prologue
Deep dark side of git - prologueDeep dark side of git - prologue
Deep dark side of git - prologue
SeongJae Park
 

More from SeongJae Park (20)

Biscuit: an operating system written in go
Biscuit:  an operating system written in goBiscuit:  an operating system written in go
Biscuit: an operating system written in go
 
GCMA: Guaranteed Contiguous Memory Allocator
GCMA: Guaranteed Contiguous Memory AllocatorGCMA: Guaranteed Contiguous Memory Allocator
GCMA: Guaranteed Contiguous Memory Allocator
 
Linux Kernel Memory Model
Linux Kernel Memory ModelLinux Kernel Memory Model
Linux Kernel Memory Model
 
An Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux KernelAn Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux Kernel
 
Design choices of golang for high scalability
Design choices of golang for high scalabilityDesign choices of golang for high scalability
Design choices of golang for high scalability
 
Brief introduction to kselftest
Brief introduction to kselftestBrief introduction to kselftest
Brief introduction to kselftest
 
Understanding of linux kernel memory model
Understanding of linux kernel memory modelUnderstanding of linux kernel memory model
Understanding of linux kernel memory model
 
Let the contribution begin (EST futures)
Let the contribution begin  (EST futures)Let the contribution begin  (EST futures)
Let the contribution begin (EST futures)
 
gcma: guaranteed contiguous memory allocator
gcma:  guaranteed contiguous memory allocatorgcma:  guaranteed contiguous memory allocator
gcma: guaranteed contiguous memory allocator
 
Sw install with_without_docker
Sw install with_without_dockerSw install with_without_docker
Sw install with_without_docker
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot public
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
 
Deep dark side of git - prologue
Deep dark side of git - prologueDeep dark side of git - prologue
Deep dark side of git - prologue
 
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSDO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
 
Experimental android hacking using reflection
Experimental android hacking using reflectionExperimental android hacking using reflection
Experimental android hacking using reflection
 
ash
ashash
ash
 
Hacktime for adk
Hacktime for adkHacktime for adk
Hacktime for adk
 
Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution begin
 
Touch Android Without Touching
Touch Android Without TouchingTouch Android Without Touching
Touch Android Without Touching
 
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기   dev festx korea 2012 presentationAOSP에 컨트리뷰션 하기   dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentation
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Develop Android/iOS app using golang

  • 2. This work by SeongJae Park is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons. org/licenses/by-sa/3.0/.
  • 3. This slides were presented during GopherCon Korea 2015 (https://plus.google.com/u/0/events/c4b79ocq4k9ac11bpb5b2govkes)
  • 4. Nice To Meet You SeongJae Park sj38.park@gmail.com golang newbie programmer
  • 5. Warning ● This speech could be useless for you ○ The speaker is doing this just for fun https://github.com/golang/mobile/raw/master/doc/caution.png
  • 6. Warning ● This speech could be useless for you ○ The speaker is doing this just for fun ● Don’t try this at office carelessly ○ It’s an experiment yet https://github.com/golang/mobile/raw/master/doc/caution.png
  • 7. Java is Dangerous, Now ● Oracle may take Java away from Android ● Swift is open source now, but... ● We need alternatives http://img.talkandroid.com/uploads/2011/10/OracleGoogle.jpg
  • 8. golang: Programming Language ● For simple, reliable, and efficient software. http://blog.golang.org/5years/gophers5th.jpg
  • 9. golang: Programming Language ● For simple, reliable, and efficient software. ● Could it be used for simple, reliable, efficient, and free mobile application? http://blog.golang.org/5years/gophers5th.jpg
  • 10. Golang on Mobile ● Golang supports Android from v1.4 ● Golang supports iOS from v1.5 ○ Though it’s still in experimental stage, there were many improvements especially in tools ● https://github.com/golang/mobile ○ Repo of packages and tools for Go on Mobile
  • 11. Goal of This Speak ● Showing how we can use golang on Mobile ○ Focus on Android, rather than iOS (Speaker has no iPhone…) ○ By exploring example code
  • 12. Goal of This Speak ● Showing how we can use golang on Mobile ○ Focus on Android, rather than iOS (Speaker has no iPhone…) ○ By exploring example code ● We will explore code based on go1.4, go1.5 ○ Code based on go1.4 shows naked face of build process ■ based on go1.4: https://github.com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f5725a5cbcd6b ■ based on go1.5: https://github.com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c555366d20
  • 13. Pre-requisites ● Basic development environment(vim, git, gcc, java, gradle, …) http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
  • 14. Pre-requisites ● Basic development environment(vim, git, gcc, java, gradle, …) ● Android SDK & NDK http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
  • 15. Pre-requisites ● Basic development environment(vim, git, gcc, java, gradle, …) ● Android SDK & NDK ● Golang 1.4 cross-compiled for GOOS=android or higher versions http://www.theprospect.net/wp-content/uploads/2014/02/one-does-not-simply-skip-a-step.jpg
  • 16. Pure Golang Mobile App NO JAVA!
  • 17. Main Idea: NDK ● c / c++ only apk is available using NativeActivity ○ Golang is a compiled language, too. Why not? http://www.android.pk/images/android-ndk.jpg
  • 18. Main Idea: NDK ● c / c++ only apk is available using NativeActivity ○ Golang is a compiled language, too. Why not? Plan is as below: ● Build golang program as .so file ○ ELF shared object ● Process events(draw, touch, …) via OpenGL ● Build NativeActivity apk using NDK / SDK http://www.android.pk/images/android-ndk.jpg
  • 19. Example Code https://github. com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f57 25a5cbcd6b/example/basic for 1.4 based https://github. com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c 555366d20/example/basic for 1.5 based
  • 20. Example Code (1.4 based) https://github. com/golang/mobile/tree/40f92f7d9f9092072ea68570fd6f57 25a5cbcd6b/example/basic $ tree . ├── all.bash ├── all.bat ├── AndroidManifest.xml ├── build.xml ├── jni │ └── Android.mk ├── main.go ├── make.bash └── make.bat 1 directory, 8 files
  • 21. main.go: Register Callbacks Register callbacks from golang entrypoint (After 1.5, programming model changed a little) func main() { app.Run(app.Callbacks{ Start: start, Stop: stop, Draw: draw, Touch: touch, }) } (mobile/example/basic/main.go)
  • 22. main.go: Use OpenGL func draw() { gl.ClearColor(1, 0, 0, 1) ... green += 0.01 if green > 1 { green = 0 } gl.Uniform4f(color, 0, green, 0, 1) ... debug.DrawFPS() } (mobile/example/basic/main.go)
  • 23. NativeActivity NativeActivity only application doesn’t need JAVA <application android:label="Basic" android:hasCode="false"> <activity android:name="android.app.NativeActivity" android:label="Basic" android:configChanges="orientation|keyboardHidden"> <meta-data android:name="android.app.lib_name" android:value="basic" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> (mobile/example/basic/AndroidManifest.xml)
  • 24. NativeActivity NativeActivity only application doesn’t need JAVA <application android:label="Basic" android:hasCode="false"> <activity android:name="android.app.NativeActivity" android:label="Basic" android:configChanges="orientation|keyboardHidden"> <meta-data android:name="android.app.lib_name" android:value="basic" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> (mobile/example/basic/AndroidManifest.xml)
  • 25. NativeActivity NativeActivity only application doesn’t need JAVA <application android:label="Basic" android:hasCode="false"> <activity android:name="android.app.NativeActivity" android:label="Basic" android:configChanges="orientation|keyboardHidden"> <meta-data android:name="android.app.lib_name" android:value="basic" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> (mobile/example/basic/AndroidManifest.xml)
  • 26. Build Process Build golang code into ELF shared object for ARM mkdir -p jni/armeabi CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-shared" -o jni/armeabi/libbasic.so . ndk-build NDK_DEBUG=1 ant debug (mobile/example/basic/make.bash)
  • 27. Build Process Build golang code into ELF shared object for ARM NDK to add the so file mkdir -p jni/armeabi CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-shared" -o jni/armeabi/libbasic.so . ndk-build NDK_DEBUG=1 ant debug (mobile/example/basic/make.bash)
  • 28. Build Process Build golang code into ELF shared object for ARM NDK to add the so file SDK to build apk file mkdir -p jni/armeabi CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-shared" -o jni/armeabi/libbasic.so . ndk-build NDK_DEBUG=1 ant debug (mobile/example/basic/make.bash)
  • 29. Example Code (1.5 based) https://github. com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c 555366d20/example/basic gomobile command do build $ tree . └── main.go 0 directories, 1 file
  • 30. Example Code (1.5 based) https://github. com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c 555366d20/example/basic gomobile command do build $ go get golang.org/x/mobile/cmd/gomobile $ tree . └── main.go 0 directories, 1 file
  • 31. Example Code (1.5 based) https://github. com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c 555366d20/example/basic gomobile command do build $ go get golang.org/x/mobile/cmd/gomobile $ gomobile init # install ndk if needed $ tree . └── main.go 0 directories, 1 file
  • 32. Example Code (1.5 based) https://github. com/golang/mobile/tree/25faf494e186f45f8d9704fb53a6c6c 555366d20/example/basic gomobile command do build $ go get golang.org/x/mobile/cmd/gomobile $ gomobile init # install ndk if needed $ gomobile build -target=android golang.org/x/mobile/example/basic $ tree . └── main.go 0 directories, 1 file
  • 33. Pure Golang Android App Pros: No more JAVA! Yay!!! Cons: Should I learn OpenGL to show a cat?
  • 34. Golang as a Library Cooperate Java and Golang
  • 35. Main Idea: Gives binding Java and C language connected via JNI Java C JNI
  • 36. Main Idea: Gives binding Java and C language connected via JNI C language and Golang connected via cgo Java C GO JNI CGO
  • 37. Main Idea: Gives binding Java and C language connected via JNI C language and Golang connected via cgo ObjC(Objective C) is a super-set of C language Java C GO JNI CGO ObjC
  • 38. Main Idea: Gives binding Java and C language connected via JNI C language and Golang connected via cgo ObjC(Objective C) is a super-set of C language Golang supports Java/ObjC-Golang bind (Uses Cgo internally) Java C GO JNI CGO bind ObjC bind
  • 39. Example Code (1.4 based) https://github. com/golang/mobile/tree/40f92 f7d9f9092072ea68570fd6f572 5a5cbcd6b/example/libhello
  • 40. Example Code (1.4 based) https://github. com/golang/mobile/tree/40f92 f7d9f9092072ea68570fd6f572 5a5cbcd6b/example/libhello $ tree . ├── all.bash ├── all.bat ├── AndroidManifest.xml ├── build.xml ├── hi │ ├── go_hi │ │ └── go_hi.go │ └── hi.go ├── main.go ├── make.bash ├── make.bat ├── README └── src ├── com │ └── example │ └── hello │ └── MainActivity.java └── go └── hi └── Hi.java 8 directories, 12 files
  • 41. Callee in Go Golang code is implementing Hello() function func Hello(name string) { fmt.Printf("Hello, %s!n", name) } (mobile/example/libhello/hi/hi.go)
  • 42. Caller in JAVA Java code is calling Golang function, Hello() protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Go.init(getApplicationContext()); Hi.Hello("world"); } (mobile/example/libhello/src/com/example/hello/MainActivity.java)
  • 43. gobind generate language bindings that make it possible to call Go code and pass objects from Java $ go install golang.org/x/mobile/cmd/gobind $ gobind -lang=go github.com/libhello/hi > hi/go_hi/go_hi.go # stub $ gobind -lang=java github.com/libhello/hi > src/go/hi/Hi.java # proxy
  • 44. gobind: Generated Proxy java Code Provides wrapper function for golang calling code public static void Hello(String name) { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); _in.writeUTF16(name); Seq.send(DESCRIPTOR, CALL_Hello, _in, _out); } private static final int CALL_Hello = 1; private static final String DESCRIPTOR = "hi"; (mobile/example/libhello/src/go/hi/Hi.java)
  • 45. gobind: Generated Stub go Code Provides proxy and registering for the exported function func proxy_Hello(out, in *seq.Buffer) { param_name := in.ReadUTF16() hi.Hello(param_name) } func init() { seq.Register("hi", 1, proxy_Hello) } (mobile/example/libhello/hi/go_hi/go_hi.go)
  • 46. Example Code (1.5 based) https://github. com/golang/mobile/tree/25faf 494e186f45f8d9704fb53a6c6 c555366d20/example/bind gomobile do binding automatically $ gomobile bind -target=android golang.org/x/mobile/example/bind/hello $ tree . ├── android │ ├── README ├── ... │ └── settings.gradle ├── hello │ └── hello.go └── ios ├── bind │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Info.plist │ ├── main.m │ ├── ViewController.h │ └── ViewController.m ├── bind.xcodeproj │ └── project.pbxproj └── README
  • 47. Golang as a Library Pros: JAVA for UI, Golang for background (Looks efficient enough)
  • 48. Golang as a Library Pros: JAVA for UI, Golang for background (Looks efficient enough) Cons: Binding supports only subset of Go types
  • 50. Main Idea: Android is a Linux http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png Android is a variant of Linux system with ARM x86 Androids exist, though...
  • 51. Main Idea: Android is a Linux http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png Android is a variant of Linux system with ARM x86 Androids exist, though... Go supports ARM & Linux Officially with static-linking
  • 52. Main Idea: Android is a Linux http://www.kitguru.net/wp-content/uploads/2012/03/linux-android.png Android is a variant of Linux system with ARM x86 Androids exist, though... Go supports ARM & Linux Officially with static-linking Remember the philosophy of Unix Not tested for iOS
  • 54. Example Code https://github.com/sjp38/goOnAndroid https://github.com/sjp38/goOnAndroidFA Were demonstrated as live-coding from GDG Korea DevFair 2014 (http://devfair2014. gdg.kr/) and GDG Golang Seoul Meetup 2015 (https: //developers.google. com/events/5381849181323264/)
  • 55. Golang Process on Android: Plan 1. Cross compile Go program as ARM / Linux
  • 56. Golang Process on Android: Plan 1. Cross compile Go program as ARM / Linux 2. Include the binary in assets/ of Android app
  • 57. Golang Process on Android: Plan 1. Cross compile Go program as ARM / Linux 2. Include the binary in assets/ of Android app 3. Copy the binary in private space of the app
  • 58. Golang Process on Android: Plan 1. Cross compile Go program as ARM / Linux 2. Include the binary in assets/ of Android app 3. Copy the binary in private space of the app 4. Give execute permission to the binary /data/data/com.example.goRunner/files # ls -al -rwxrwxrwx u0_a55 u0_a55 4512840 2014-11-28 17:45 gobin
  • 59. Golang Process on Android: Plan 1. Cross compile Go program as ARM / Linux 2. Include the binary in assets/ of Android app 3. Copy the binary in private space of the app 4. Give execute permission to the binary 5. Execute it /data/data/com.example.goRunner/files # ls -al -rwxrwxrwx u0_a55 u0_a55 4512840 2014-11-28 17:45 gobin
  • 60. Go bin Loading Load golang program from assets to private dir private void copyGoBinary() { String dstFile = getBaseContext().getFilesDir().getAbsolutePath() + "/verChecker.bin"; try { InputStream is = getAssets().open("go.bin"); FileOutputStream fos = getBaseContext().openFileOutput( "verChecker.bin", MODE_PRIVATE); byte[] buf = new byte[8192]; int offset; while ((offset = is.read(buf)) > 0) { fos.write(buf, 0, offset); } Runtime.getRuntime().exec("chmod 0777 " + dstFile); } catch (IOException e) { } }
  • 61. Execute Go process Spawn new process for the program and communicates using stdio ProcessBuilder pb = new ProcessBuilder(); pb.command(goBinPath()); pb.redirectErrorStream(false); goProcess = pb.start(); new CopyToAndroidLogThread("stderr", goProcess.getErrorStream()) .start();
  • 62. Inter Process Communication Pros: Just normal unix way
  • 63. Inter Process Communication Pros: Just normal unix way Golang team is using this for Camlistore (https://github.com/camlistore/camlistore)
  • 64. Inter Process Communication Pros: Just normal unix way Golang team is using this for Camlistore (https://github.com/camlistore/camlistore) Cons: Hacky, a little x/mobile is comfortable enough, now Not sure whether it works on iOS
  • 65. Summary ● Go can run on Mobile ○ As a native application, ○ as a library, ○ or, as a process ● Though it’s an experiment yet, it’s fairly comfortable