gioui.org/ui@v0.0.0-20190926171558-ce74bc0cbaea/app/runmain.go (about) 1 // +build android darwin,ios 2 3 package app 4 5 // Android only supports non-Java programs as c-shared libraries. 6 // Unfortunately, Go does not run a program's main function in 7 // library mode. To make Gio programs simpler and uniform, we'll 8 // link to the main function here and call it from Java. 9 10 import ( 11 "sync" 12 _ "unsafe" // for go:linkname 13 ) 14 15 //go:linkname mainMain main.main 16 func mainMain() 17 18 var runMainOnce sync.Once 19 20 func runMain() { 21 runMainOnce.Do(func() { 22 // Indirect call, since the linker does not know the address of main when 23 // laying down this package. 24 fn := mainMain 25 go fn() 26 }) 27 }