Giter VIP home page Giter VIP logo

go-indie-boiler's Introduction

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).

go-indie-boiler's People

Contributors

davidnix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.