Skip to content
/ indie Public

A Go stack for indie hacker or early stage projects

License

Notifications You must be signed in to change notification settings

DavidNix/indie

Repository files navigation

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.

Important: This is not a framework. It's boilerplate. A template.

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

The Stack

  • Go (duh)
  • Cobra for cli
  • Echo for web server and router
  • HTMX for dynamic web pages
  • Templ for HTML templates
  • Ent for database/ORM
  • Air for live reload
  • Testify for test matchers

Fat free! No npm, npx, yarn, pnpm, webpack, and whatever else the Front End World conjures up.

Use as Project Template

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>

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

Run the server:

make run

Live reload:

make watch

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

Features

Development Speed

Using ent allows automatic migrations. At scale, this is bad. But for iterating quickly, it's great.

Ent lets us use an in-memory sqlite database for unit tests. This is a huge win for speed.

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 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 hopefully has the Lindy Effect.

Wait, an ORM?!

Those who know me will be shocked I'm using an ORM. (I typically despise them.)

But hear me out. In this context (getting a project off the ground at light speed), it's a good fit:

  • Validation out of the box.
  • Unit tests with in-memory sqlite.
  • Automatic migrations.

If your project grows and becomes more complex, you should move off Ent (the ORM).

About

A Go stack for indie hacker or early stage projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published