structure appears to work
Some checks failed
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone Build is failing

This commit is contained in:
2024-09-12 11:59:41 +10:00
parent eb10ca9ca3
commit 18a2b7227e
25 changed files with 841 additions and 125 deletions

View File

@@ -1,17 +1,17 @@
# Go + HTMX Template
This is a template repository that comes with everything you need to build a Web Application using Go (templ) and HTMX.
This is built from the template https://github.com/Piszmog/go-htmx-template that comes with everything you need to build a Web Application using Go (templ) and HTMX.
The template comes with a basic structure of using a SQL DB (`sqlc`), E2E testing (playwright), and styling (tailwindcss).
## Getting Started
In the top right, select the dropdown __Use this template__ and select __Create a new repository__.
Clone https://github.com/Piszmog/go-htmx-template
Once cloned, run the `update_module.sh` script to change the module to your module name.
```shell
./update_module vctpule
./update_module my-new-module
```
## Technologies
@@ -28,8 +28,8 @@ A few different technologies are configured to help getting off the ground easie
- The script `upgrade_templ.sh` is available to make upgrading easier
- [HTMX](https://htmx.org/) for HTML interaction
- The script `upgrade_htmx.sh` is available to make upgrading easier
- [air](https://github.com/cosmtrek/air) for live reloading of the application.
- [golang migrate](https://github.com/golang-migrate/migrate) for DB migrations.
- [golang migrate](https://github.com/golang-migrate/migrate) for DB migrations, TODO replace with [goose](https://github.com/pressly/goose)
- [playwright-go](https://github.com/playwright-community/playwright-go) for E2E testing.
Everything else uses the standard library.
@@ -97,7 +97,17 @@ This is where `templ` files live. Anything you want to render to the user goes h
This is the directory that `sqlc` generates to. Update `queries.sql` to build
your database operations.
This project uses [golang migrate](https://github.com/golang-migrate/migrate) for DB
#### DB Migrations
This project now uses [goose](https://github.com/pressly/goose) for DB migrations.
Install via `brew install goose` on a mac, or install via golang with command `go install github.com/pressly/goose/v3/cmd/goose@latest`
```shell
goose -dir db/migrations sqlite3 ./db.sqlite3 create init sql
```
#### Deprecated
This project no longer uses [golang migrate](https://github.com/golang-migrate/migrate) for DB
migrations. `sqlc` uses the `db/migrations` directory to generating DB tables. Call
`db.Migrate(..)` to automatically migrate your database to the latest version. To add migration
call the following command,
@@ -108,6 +118,7 @@ migrate create -ext sql -dir db/migrations <name of migration>
This package can be easily update to use `sqlx` as well.
### Dist
This is where your assets live. Any Javascript, images, or styling needs to go in the
@@ -179,35 +190,16 @@ commands.
### Prerequisites
- Install [templ](https://templ.guide/quick-start/installation)
- Install [templ](https://templ.guide/quick-start/installation) - `go install github.com/a-h/templ/cmd/templ@latest`
- Install [sqlc](https://docs.sqlc.dev/en/stable/overview/install.html)
- Install [tailwindcss CLI](https://tailwindcss.com/docs/installation)
- Install [air](https://github.com/cosmtrek/air#installation)
### air
`air` has been configured with the file `.air.toml` to allow live reloading of the application
when a file changes.
To run, install `air`
#### tailwindcss
```shell
go install github.com/cosmtrek/air@latest
```
Then simply run the command
```shell
air
```
#### Address Already In Use Error
Sometimes, you may run into the issue _address already in use_. If this is the case, you
can run this command to find the PID to kill it.
```shell
ps aux | grep tmp/main
# Example for macOS arm64
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64
chmod +x tailwindcss-macos-arm64
sudo mv tailwindcss-macos-arm64 /usr/local/bin/tailwindcss
```
### Makefile