Skip to content

atos-digital/10.10.0-template

Repository files navigation

10.10.0 App

Getting started

Running the app

You must be on MacOS/Linux in order to use Make. Windows users can install WSL to use Make.

Quick start

Install:

  • go Note: ensure you have the gobin on your path
  • node

N.B. These are just the official install pages, you can use your package manager of choice.

Once installed, we need a few tools to be available on the command line.

Run the following command:

We use Tailwind for styling, and Prettier for formatting.

npm install -g prettier tailwindcss

We use templ to generate the HTML pages from Go.

go install github.com/a-h/templ/cmd/templ@latest

For building and auto rebuild we user air

go install github.com/cosmtrek/air@latest

To simply run the app, run the following command from the root of the project:

make

Note: You may need to clone the .env.example file to .env first, although the make command will do this for you.

How this works

The basic premise is that we use HTMX to make the app interactive. This means that we can use Go to render the initial page, and then use HTMX to make the app interactive.

Golang serves the pages by using templ to generate pages and serving them via standard handlers. Tailwind is used to style the components made in templ.

Air is simply used to reload on change and run the tailwind and templ commands on change.

The key command that does all of this is in the .air.toml file:

cmd = "npx tailwindcss -i ./ui/styles.css -o ./internal/server/assets/css/styles.css && templ generate && go build -o ./tmp/main cmd/server/main.go"

Here we can see that we are running the tailwind command, then the templ command, and then building the app.