go-app

Getting Started

GoApp is a package for building fast and modern Progressive Web Apps (PWAs) using Go and WebAssembly.

Overview

It allows you to build web user interfaces using Go syntax by composing HTML-based components. Here’s a minimal “Hello World” example:

func newHello() app.Composer {
    return &hello{}
}

type hello struct {
    app.Compo
}

func (h *hello) Render() app.UI {
    return app.H1().Text("Hello World!")
}

The component is then associated with a path using an HTTP handler that follows the Go standard library model:

func main() {
    app.Route("/", newHello)
    app.RunWhenOnBrowser()

    http.Handle("/", &app.Handler{
        Name:        "Hello",
        Description: "A Hello World example",
    })

    if err := http.ListenAndServe(":8000", nil); err != nil {
        log.Fatal(err)
    }
}

The program is compiled into two binaries: