// package lorca_gui -- тип десктопного приложения для lorca package lorca_gui import ( "fmt" "github.com/zserge/lorca" ) // ЛоркаГуи -- тип десктопного приложения для lorca type ЛоркаГуи struct{} // НовЛоркаГуи -- создание нового типа десктопного приложения для lorca func НовЛоркаГуи() (*ЛоркаГуи, error) { ui, _ := lorca.New("", "", 480, 320) defer ui.Close() // Bind Go function to be available in JS. Go function may be long-running and // blocking - in JS it's represented with a Promise. ош := ui.Bind("add", func(a, b int) int { return a + b }) if ош != nil { return nil, fmt.Errorf("НовЛоркаГуи(): ош=\n\t%w", ош) } // Call JS function from Go. Functions may be asynchronous, i.e. return promises n := ui.Eval(`Math.random()`).Float() fmt.Println(n) // Call JS that calls Go and so on and so on... m := ui.Eval(`add(2, 3)`).Int() fmt.Println(m) // Wait for the browser window to be closed <-ui.Done() return &ЛоркаГуи{}, nil }