Files
gio/app/runmain.go
Elias Naur 3879921b80 app: [API] remove Main
All platforms already allow the omission of the call to Main and running
Windows on the main goroutine. This change just gets rid of Main, and
documents the special requirement on Window.Event.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-02-08 18:53:33 +00:00

31 lines
689 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
//go:build android || (darwin && ios)
// +build android darwin,ios
package app
// Android only supports non-Java programs as c-shared libraries.
// Unfortunately, Go does not run a program's main function in
// library mode. To make Gio programs simpler and uniform, we'll
// link to the main function here and call it from Java.
import (
"sync"
_ "unsafe" // for go:linkname
)
//go:linkname mainMain main.main
func mainMain()
var runMainOnce sync.Once
func runMain() {
runMainOnce.Do(func() {
// Indirect call, since the linker does not know the address of main when
// laying down this package.
fn := mainMain
go fn()
})
}