apps: drop init funcs

Now that Gio runs main functions everywhere, init func are no longer
necessary.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-22 11:39:34 +02:00
parent c080a54038
commit b45222b457
3 changed files with 14 additions and 22 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ module gioui.org/apps
go 1.12
require (
gioui.org/ui v0.0.0-20190721200230-1ee8c08f3bf9
gioui.org/ui v0.0.0-20190722093309-c080a54038a6
github.com/google/go-github/v24 v24.0.1
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9
+12 -15
View File
@@ -126,25 +126,12 @@ var theme struct {
}
func main() {
flag.Parse()
initProfiling()
if *token == "" {
fmt.Println("The quota for anonymous GitHub API access is very low. Specify a token with -token to avoid quota errors.")
fmt.Println("See https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line.")
}
app.Main()
}
func initProfiling() {
if !*profile {
return
}
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
}
func init() {
flag.Parse()
initProfiling()
go func() {
fonts.regular = mustLoadFont(goregular.TTF)
fonts.bold = mustLoadFont(gobold.TTF)
@@ -164,6 +151,16 @@ func init() {
log.Fatal(err)
}
}()
app.Main()
}
func initProfiling() {
if !*profile {
return
}
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
}
func colorMaterial(ops *ui.Ops, color color.RGBA) ui.MacroOp {
+1 -6
View File
@@ -20,18 +20,13 @@ import (
)
func main() {
app.Main()
}
// On iOS and Android main will never be called, so
// setting up the window must run in an init function.
func init() {
go func() {
w := app.NewWindow(nil)
if err := loop(w); err != nil {
log.Fatal(err)
}
}()
app.Main()
}
func loop(w *app.Window) error {