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