github.com/gop9/olt@v0.0.0-20200202132135-d956aad50b08/gio/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/gop9/olt/gio/app/internal/window" 10 ) 11 12 // extraArgs contains extra arguments to append to 13 // os.Args. The arguments are separated with |. 14 // Useful for running programs on mobiles where the 15 // command line is not available. 16 // Set with the go linker flag -X. 17 var extraArgs string 18 19 func init() { 20 if extraArgs != "" { 21 args := strings.Split(extraArgs, "|") 22 os.Args = append(os.Args, args...) 23 } 24 } 25 26 // DataDir returns a path to use for application-specific 27 // configuration data. 28 // On desktop systems, DataDir use os.UserConfigDir. 29 // On iOS NSDocumentDirectory is queried. 30 // For Android Context.getFilesDir is used. 31 // 32 // BUG: DataDir blocks on Android until init functions 33 // have completed. 34 func DataDir() (string, error) { 35 return dataDir() 36 } 37 38 // Main must be called from the a program's main function. It 39 // blocks until there are no more windows active. 40 // 41 // Calling Main is necessary because some operating systems 42 // require control of the main thread of the program for 43 // running windows. 44 func Main() { 45 window.Main() 46 }