
go-app
What is go-app?
Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm).
Shaping a UI is done by using a declarative syntax that creates and composes HTML elements only by using the Go programing language.
Served with Go standard HTTP model, apps created with go-app are SEO friendly, installable, and support offline mode.
Updates
2022 Sat Mar 26 | go-app v9.4.0 is now available |
2021 Thu Dec 23 | go-app v9.3.0 is now available |
2021 Wed Nov 3 | go-app v9.2.0 is now available |
2021 Wed Sept 22 | go-app v9 is now available |
Declarative Syntax
Go-app uses a declarative syntax so you can write reusable component-based UI elements just by using the Go programming language.
// A component that displays a Hello world by composing with HTML elements,
// conditions, and binding.
type hello struct {
app.Compo
name string
}
func (h *hello) Render() app.UI {
return app.Div().Body(
app.H1().Body(
app.Text("Hello, "),
app.If(h.name != "",
app.Text(h.name),
).Else(
app.Text("World!"),
),
),
app.P().Body(
app.Input().
Type("text").
Value(h.name).
Placeholder("What is your name?").
AutoFocus(true).
OnChange(h.ValueTo(&h.name)),
),
)
}
Standard HTTP Server
Serving an app built with go-app is done by using the Go standard HTTP model.
func main() {
// Go-app component routing (client-side):
app.Route("/", &hello{})
app.Route("/hello", &hello{})
app.RunWhenOnBrowser()
// Standard HTTP routing (server-side):
http.Handle("/", &app.Handler{
Name: "Hello",
Description: "An Hello World! example",
})
if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatal(err)
}
}
Other Features
- Works as a Single-page application
- SEO friendly
- Installable
- Offline mode support
- State management