2025-01-01 23:18:59 -05:00
WIP
2025-01-01 23:18:59 -05:00
WIP
2024-12-09 18:04:39 -05:00
WIP
2025-01-01 23:18:59 -05:00
2024-11-11 13:48:04 -05:00
WIP
2025-01-01 23:18:59 -05:00
WIP
2024-12-09 18:04:39 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-24 07:06:22 -05:00
WIP
2024-12-09 18:04:39 -05:00
WIP
2024-12-09 18:04:39 -05:00
2025-01-01 22:32:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-13 14:50:46 -05:00
2024-11-24 06:23:37 -05:00
2024-11-24 06:23:37 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00
2024-11-11 13:48:04 -05:00

Golang Site Template

What this project isn't

  • A library
  • A framework

What is this project?

  • A template, a starting point. An inspiration, maybe?

This project is a demo, of sorts, really. It is the base for my next side project, which you can find at markbailey.dev. This project is a culmination of many, many hours poring over Go documentation, others' Go code, and questions I wanted answers to, left over from previous experimentation with a popular web framework for Go. This project is a full stack application.

This is a template for a full stack web application written in Golang. It is fully-featured, and includes a number of tools to bootstrap a project on top of what is already here. This project is a work in progress, it will be updated and maintained for the foreseeable future. This is a labor of love, learning, and a desire to build software that intrigues me outside of my day-to-day work.

I chose Go for this project because I wanted to explore the language, and the concepts it lends itself well to. You will notice that this project contains a number of features and patterns found in large scale projects. This is intentional, as in my day-to-day work I write fullstack PHP in the Symfony framework. I wanted to mirror the patterns I use at work in this project, and it has proven to be a huge boost in my understanding of both Go and the patterns, tools, and paradigms I use at work. Much of this project has been influenced by the advice of my incredible mentor, friend, and boss Andy, and my guru level senior developer. I have accumulated here the best practices that I have learned from them, from my own experience, and from the tenacious push in the Go community to write clean, idiomatic, and readable code.

It contains these features and more:

  • Middleware (Fully customizable, custom)
  • Routing and sub-routing
  • In-memory sessions
  • Templating
  • Database interaction
    This one is special, because the project uses an SQLite3 database for local development, and a PostgreSQL database for production.
  • Password authentication
  • Project management via the bin/app script

This site is currently powering my personal site, which is self hosted on a VPS. One of my favorite features of this project is the low number of dependencies. Check out the following excerpt from go.mod (As of 2024-11-11).

require (
    github.com/a-h/templ v0.2.793
    github.com/golang-jwt/jwt/v5 v5.2.1
    github.com/lib/pq v1.10.9
    github.com/mattn/go-sqlite3 v1.14.24
    golang.org/x/crypto v0.27.0
)

There are only seven dependencies in this project, two of them being just database drivers. There are also the "hidden" dependencies of sqlc, and TailwindCSS. I like to think there are actually only five, if we don't count the obligatory database drivers.

Project Statistics

project statistics

Setup

  1. Install Go
  2. Select a useable IDE:
    • GoLand (JetBrains)
    • Neovim
      • Install gopls LSP using Mason and enable it in your lspconfig
      • Set up formatting with gofumpt and goimports
    • VSCode
      • I don't use it, and I wouldn't recommend it. But you do you, boo :)
  3. Clone project: git clone https://git.markbailey.dev/cerbervs/ptpp.git
  4. Run: make first-install
  5. Access the development site at http://localhost:8080 or access the live site at

Project Management Through bin/app

bin/app is a script that manages the project from top to bottom.
Please consult the help menu for more information: bin/app help

When starting from a fresh clone of the project, run bin/app first-install to set up the project. This will install several binaries, and the required node packages. You may be required to enter your password.

Git Conventions

Making Branches

Branches should be prefixed with one of the following

  • feat/
  • fix/
  • refactor/
  • test/

Followed by a short description of the proposed changeset separated-by-hyphens

Committing Code

This project uses
Conventional Commits (Angular), and in the future, Commitlint

Description
Full-stack site template using Go, HTMX, Templ, SQLite, and PostgreSQL
Readme 2.2 MiB
Languages
Go 71.1%
Shell 18.7%
CSS 7.3%
Dockerfile 1.8%
JavaScript 1.1%