indie

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2025 License: MIT

README

Indie

Opinionated Go boilerplate for the indie hacker or early stage projects.

indie-logo.png

Why does JS, Rails, Django, and Phoenix have all the fun?

Let's use a Go stack for quickly building ideas.

After you create your project, use or discard what you wish.

This is used as a boilerplate and library.

Boilerplate

Install the experimental gonew command.

go install golang.org/x/tools/cmd/gonew@latest

Then in a fresh directory:

gonew github.com/DavidNix/indie github.com/<YOUR_USER>/<YOUR_PROJECT_NAME>

Library

TODO

The Stack

  • Go (of course)
  • Cobra for cli
  • Echo for web server and router
  • HTMX for dynamic web pages (although I'm considering moving to datastar)
  • Templ for HTML templates
  • Overmind for local development (a lightweight docker compose that doesn't need docker)
  • Tailwind CSS for the utility-first CSS framework
  • DaisyUI 5 for tailwind components because Daisy doesn't need JS

Local development

All funneled through make.

To see what you can do:

make

Then (assumes you have homebrew installed):

make setup

Generate code:

make gen

Live reload:

make watch

Caveat: Any ent (data model) changes will require a manual restart.

Features

Reasonable Security

The license still stands that this software is provided as-is with no warranty.

But I've tried to make reasonable security decisions such as server timeouts, CSRF protection, and secure headers.

Design Decisions

Why Echo?

I like Echo's handler signature where you return an error. They also have nice middleware.

I first tried Fiber which uses fasthttp as the router. Unfortunately, fasthttp has a nasty race condition when using database/sql. Also, Fiber makes you choose between c.Context() and c.UserContext() which is confusing.

Also, Echo is one of the older Go http frameworks, so has the Lindy Effect.

No ORM or database library?

BYO database implementation. There's an example of how I like to do migrations with sqlite.

I typically don't like ORMs, but sometimes I use ent if I need speed of development. Also, ORMs let you compose dynamic queries a bit easier than compiled solutions like sqlc.

Many prefer sqlc. Or, if simple enough, just use database/sql.

No AplineJS?

I found writing vanilla JS suited my needs just fine.

Directories

Path Synopsis
Package asset contains utilities for serving static asset service like images, css, js, and other files.
Package asset contains utilities for serving static asset service like images, css, js, and other files.
cmd
indie command
Package email allows sending transactional and marketing emails via Sendgrid.
Package email allows sending transactional and marketing emails via Sendgrid.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL