This project provides some working examples using Go the hotwire/turbo library published by basecamp. This is based on a great post about Hotwire: HTML Over The Wire by @delitescere.
This service illustrates how to use turbo to enable updates to a website using primarily service side code.
- Uses html/template via my helper library echo-go-templates which provides layout helpers, and embedded assets with io/fs for views.
- Uses echo library to simplify routing.
- Uses a CDN to host all css / JS libraries base.html.
- Uses esbuild to automatically bundle JS assets on startup using echo-esbuild-middleware to serve them.
In this site I have implemented:
Most of the server side logic is in hotwire.go.
- Go 1.13 or later with support for Go Modules, used to build the service.
- Node.js 12 or later, which is only used to install our asset building dependencies.
To get this project running you need to setup some certificates, in my case I use https://github.com/FiloSottile/mkcert and there is a target in the makefile.
make certs
To install node dependencies
make install
To start the service just run.
make start
For development you can use the following command, this will check for code updates and restart the service.
make watch
The service should be listening on https://hotwire.localhost:9443/
This application is released under Apache 2.0 license and is copyright Mark Wolfe.