Open source

go-webthings

Small Go packages for HTML-first websites.

go-webthings is a family of focused packages for server-rendered Go applications that still want sharp interactivity. The pieces stay small: routing is routing, template knowledge is documented, and partial rendering is explicit.

You work with ordinary net/http and normal html/template files, and get HTMX-friendly updates without turning the browser into the main application runtime.

Three packages, one HTML response

Requests are routed by go-router, template contracts are described by go-clue, and full pages or HTMX fragments are rendered by go-partial.

  1. request
  2. routego-router
  3. contractgo-clue
  4. rendergo-partial
  5. html
go-router

Host-aware routing on top of net/http: route groups, middleware, named routes, mounted routers and not-found pages, with middleware for logging, security headers, compression and output caching.

go-clue

Typed contracts and editor metadata for html/template files. Templates stay plain, while your editor can complete, navigate and diagnose model access.

go-partial

Renders full pages or just the part that's needed from the same templates: targeted HTMX updates, out-of-band swaps, selections, actions and reusable regions, without turning HTML into a component dialect.

Add the pieces you need

Forms, translations and asset preparation follow the same approach: explicit Go types and HTML-first rendering. Each package can be used on its own.

go-form

Typed HTML forms from struct tags, with submission mapping, field validation, configurable themes, request metadata and CSRF protection.

go-importmap

Vendors pinned JavaScript and CSS packages at build time with a lock file, embeds them, serves them with versioned URLs and Subresource Integrity, and generates import maps and stylesheet tags for your templates.

go-translator

Gettext PO catalogues with request-local locale selection, plural forms, translation contexts and extraction of literal keys from Go templates.

And go-webthings itself

The Go library go-webthings runs the backend of a website, built from these packages. Your site is a small Go program: you bring the templates and choose the modules. The result is a single binary, running on SQLite with no other service, or on PostgreSQL or MySQL.

  • The database and its tables, created and updated at start
  • The admin, with sign-in, two-step sign-in, password reset, accounts and groups
  • The page tree, the routes in every language and scheduled publishing
  • The media library, with resized copies of images
  • Site settings, themes, sitemap.xml, robots.txt and the site search
  • Email for the modules, through the sender you configure
app := webthings.New(webthings.Config{
    Name:      "My site",
    Locales:   locales.Config{
        Default: "en",
        Enabled: []string{"en", "nl"},
    },
    Templates: os.DirFS("templates"),
})

err := app.Use(
    publishing.Module("news", "News"),
    events.Module("agenda", "Agenda"),
)
if err != nil {
    log.Fatal(err)
}

err = app.ListenAndServe(ctx, ":8080")

Modules

You add a module with one line: its admin sections, pages, template functions and database tables come with it. The bundled modules use only the public API, so a module of your own can do everything they do.

  • Publishing
  • Events
  • Gallery
  • Forms
  • Newsletter
  • Comments
  • Polls
  • Documents
  • People
  • Directory
  • Lists
  • Banners
  • Testimonials
  • Registrations
  • Submissions
  • Redirects
  • Stats