Small, self-contained apps that each demonstrate one xtemplate feature.
The quickest way to explore them is to start everything at once:
mise run examples
This launches all six examples plus a landing page at
http://localhost:9000 with links to each one. Press Ctrl+C to stop them all.
If one of those ports is already taken, pass a different base port; everything
shifts up from there (the hub takes the base, each example the base + its
offset):
mise run examples 9100
To run just one as a dev server instead, use mise run example-<name> and open
the listed URL.
Examples 1-4 (contacts, sse-chat, blog, filebrowser) run the
default CLI binary built by mise run build-cli (dist/xtemplate) against a
config.json in the example directory.
Examples 5-6 (embedded, dotprovider) are custom Go programs (their own
main.go calling app.Main(...)) and have their own build-example-<name>
task.
Each example has:
A templates/ directory (the web root).
A tests/*.hurl smoke test. Following the convention of the main suite, the
.hurl files hardcode localhost:8080; the harness remaps that to the
example's real port with curl --connect-to, so the same files work no matter
which port the example listens on.
Tasks
mise run example-<name> - run the example as a foreground dev server.
mise run test-example-<name> - build, serve on its port, run its hurl suite, tear down.
mise run test-examples - run every example's integration test (included in mise run test / mise run ci).
Embedded single-binary example: the templates dir is compiled into the binary via //go:embed, so this binary serves its templates with no templates dir on disk at runtime.
Embedded single-binary example: the templates dir is compiled into the binary via //go:embed, so this binary serves its templates with no templates dir on disk at runtime.
Click to show internal directories.
Click to hide internal directories.
go.dev uses cookies from Google to deliver and enhance the quality of its services and to
analyze traffic. Learn more.