https://github.com/rstudio-tech/go_web_bolierplate
Web bolierplate with go
https://github.com/rstudio-tech/go_web_bolierplate
Last synced: 12 months ago
JSON representation
Web bolierplate with go
- Host: GitHub
- URL: https://github.com/rstudio-tech/go_web_bolierplate
- Owner: rstudio-tech
- License: mit
- Created: 2024-12-05T16:20:21.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-05T16:22:45.000Z (over 1 year ago)
- Last Synced: 2025-07-02T17:55:28.295Z (12 months ago)
- Language: Go
- Size: 120 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Web Starter App
Warning: This is not ready for public use. It's not even close.
This is an experiment of how to build web applications and to make an example starter web application. It is not a web
framework. It is how I prefer to start web applications.
## Prerequisites
* A Unix-like environment - Linux, Mac, or WSL
* [Go](https://go.dev/) - Backend programming language
* [asdf](https://asdf-vm.com/) - Version manager for build tools like NodeJS and Ruby
* [direnv](https://direnv.net/) - Easily manage environment variables per directory
* [watchexec](https://watchexec.github.io/) - File system watcher used to trigger rebuilds
* [Templ](https://templ.guide/) - CLI for compiling HTML templates
## Stack
### Go
* [Cobra](https://github.com/spf13/cobra) - CLI parsing
* [Chi](https://github.com/go-chi/chi) - HTTP router
* [Templ](https://github.com/a-h/templ) - Compiled HTML templates
* [Zerolog](https://github.com/rs/zerolog) - Logger
## Setup
Initialize the config files:
```
rake setup:config
```
## Creating an new PostgreSQL Cluster
Ensure your `PATH` environment variable includes the PostgreSQL bin directory for the version of PostgreSQL you want to use. e.g. `/opt/homebrew/opt/postgresql@16/bin`.
Set the `PGPORT` environment variable if you want to run the server on a different port. Typically, this is done to allow multiple PostgreSQL clusters to run on the same host. This is best set in the `.envrc` file so subsequent development in this project will automatically connect to the proper cluster.
Create a new cluster:
```
rake setup:create_postgresql_cluster
```
The cluster will be created in the `.postgresql` directory and is setup to log all queries to `stderr`.
You can run the database with:
```
rake db:cluster:run
```
## Setup PostgreSQL Database and User
Once the new cluster is running (or you skipped that step and are using an existing, running cluster) setup the database
and user:
```
rake setup:postgresql
```