github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/app/app.go (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 package app 4 5 import ( 6 "os" 7 "strings" 8 9 "github.com/cybriq/giocore/app/internal/wm" 10 ) 11 12 // ViewEvent carries the platform specific window handles for 13 // a Window. 14 // 15 // ViewEvent is implemented for Android, macOS, Windows. 16 type ViewEvent = wm.ViewEvent 17 18 // extraArgs contains extra arguments to append to 19 // os.Args. The arguments are separated with |. 20 // Useful for running programs on mobiles where the 21 // command line is not available. 22 // Set with the go linker flag -X. 23 var extraArgs string 24 25 func init() { 26 if extraArgs != "" { 27 args := strings.Split(extraArgs, "|") 28 os.Args = append(os.Args, args...) 29 } 30 } 31 32 // DataDir returns a path to use for application-specific 33 // configuration data. 34 // On desktop systems, DataDir use os.UserConfigDir. 35 // On iOS NSDocumentDirectory is queried. 36 // For Android Context.getFilesDir is used. 37 // 38 // BUG: DataDir blocks on Android until init functions 39 // have completed. 40 func DataDir() (string, error) { 41 return dataDir() 42 } 43 44 // Main must be called last from the program main function. 45 // On most platforms Main blocks forever, for Android and 46 // iOS it returns immediately to give control of the main 47 // thread back to the system. 48 // 49 // Calling Main is necessary because some operating systems 50 // require control of the main thread of the program for 51 // running windows. 52 func Main() { 53 wm.Main() 54 }