tiramisu

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

README

🍥 tiramisu

is tiramisu a cake or a pie?

Build modern, cross-platform desktop apps in HTML + Go from one codebase. It uses the built-in OS webview (WebView2 on Windows, WebKitGTK on Linux, and WebKit on macOS) to render HTML to the screen. Tiramisu creates a connection between Go and the webview, allowing you manipulate the UI and calling Go methods from the webview seamlessly.

Features

  • 💻 Cross-platform: Write once, run everywhere. Tiramisu supports Windows, macOS, and Linux.
  • 🪶 Lightweight: No need for a heavy framework. Tiramisu uses the built-in webview of the OS.
  • Fast development: Use ANY web framework for your UI. Tiramisu handles all the magic of making it work, for you.

Installation

go get -u git.iwakura.rip/grng/tiramisu

Example

package main

import (
    "fmt"
    "git.iwakura.rip/grng/tiramisu"
)

func main() {
    // create the webview instance
    app := tiramisu.New(tiramisu.TiramisuOptions{
        Title:  "Tiramisu Example",
        Width:  800,
        Height: 600,
    })

    // bind a go function to the webview
    app.Bind("hello", func(name string) string {
        return fmt.Sprintf("Hello, %s!", name)
    })

    // set the HTML content of the webview
    app.HTML(`
        <h1>Tiramisu Example</h1>
        <button onclick="tiramisu.invoke('hello', 'world').then(alert)">Greet</button>
    `)

    // t.Run() also allows you to pass a func(), which is executed on the main thread
    // before the webview is shown, so you can do any setup you need.
    app.Run(/* func() {
        // This code runs on the main thread before the webview is shown
        fmt.Println("Webview is ready!")
    }*/)
}

Building

Windows

Windows users should use the -ldflags='-H windowsgui' flag to avoid showing a console window when running the app.

go build -ldflags='-H windowsgui' ./example
*nix
go build ./example

Contributing & Development

git clone ssh://[email protected]:6969/grng/tiramisu.git
cd tiramisu
air

License

tiramisu is licensed under the GNU General Public License (GPL) v3.0. See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg

func Arg(args []any, i int) (any, error)

func ArgAs

func ArgAs[T any](args []any, i int) (T, error)

Types

type FuncHandler

type FuncHandler func(args ...any) (any, error)

type Tiramisu

type Tiramisu struct {
	// contains filtered or unexported fields
}

func New

func New(o TiramisuOptions) *Tiramisu

func (*Tiramisu) Bind

func (t *Tiramisu) Bind(name string, fn FuncHandler)

func (*Tiramisu) Eval

func (t *Tiramisu) Eval(js string)

func (*Tiramisu) Evalf

func (t *Tiramisu) Evalf(js string, args ...any)

func (*Tiramisu) HTML

func (t *Tiramisu) HTML(html string)

func (*Tiramisu) Navigate added in v0.1.4

func (t *Tiramisu) Navigate(url string)

func (*Tiramisu) Run

func (t *Tiramisu) Run(fns ...func())

type TiramisuOptions

type TiramisuOptions struct {
	Debug  bool
	Width  int
	Height int
	Title  string
	Hints  wv.Hint
}

Directories

Path Synopsis
examples
minimal command
testbench command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL