Simple template suitable for building a webapp backend MVP written in go

Overview

A Simple Go Project Template - Suited for Webapp MVPs

A simple go project structure setup with all dependencies you need to get your MVP off the ground. πŸš€

The project is suited as starting point for a simple webapp MVP. Besides the core files needed to get the setup running it contains a simple user module showcasing the intended project structure. Running the project starts the app exposing a REST API using the go-shipped webserver.

Features

  • Hot reloading. :trollface:
  • sqlite3 database for local development. ❀️
  • ORM ready to go. πŸƒ
  • A simple database migration system. πŸ™Œ
  • Injection of environment variables into config files. 🎢
  • Simple spring-like repository structure for convenient database queries. ⭐
  • Testing setup. πŸ‘·

Feedback and PRs welcome! I hope you find it useful. 🍺 πŸ•

Installation and Run Project

$ git clone https://github.com/eldonaldo/go-project-template
$ cd go-project-template

# You need to get air separately to get the hot reloading running 
$ go get -u github.com/cosmtrek/air

# Runs the project with hot reloading enabled
$ air

Interact with the app using the command line πŸ’»

$ curl localhost:8008/create?name=John
$ User with name John1 created

$ curl localhost:8008/greet?name=John
$ Hi John
$ {
$   "ID": 1,
$   "CreatedAt": "2021-04-07T21:32:14.135761+02:00",
$   "UpdatedAt": "2021-04-07T21:32:14.135761+02:00",
$   "DeletedAt": null,
$   "Name": "John"
$ }

Project Setup

  • cmd: Contains the app binaries
  • core: The app's core functionality resides here (such as database handling, migrations etc.)
  • core/db/migrations: SQL migration files go in here. Use ./scripts/migration_create.sh migration_name to create a new one. Migrations in this folder are automatically executed (in order) once upon app start.
  • scripts: Automation scripts. There is a script to bootstrap a new migration and another to downgrade an already applied migration.
  • server: Exposes the app as REST API and handles the HTTP server setup.
  • user: A user module showcasing a simple structure using repository and REST handler.

Changing the Project Name

To change the project name from go-project-name to something else you need to edit the go.mod module end edit the first line module github.com/eldonaldo/go-project-template to module github.com/your-username/your-new-name. Imports in all files need to be changed according (your IDE probably can do that for you ♻️ ). Further, you might also want change cmd/project-name and therefore you also need to change line 6 of .air.conf. But that should be it then. βœ…

Libraries Used

πŸ‘‹

You might also like...
Simple and fast template engine for Go

fasttemplate Simple and fast template engine for Go. Fasttemplate performs only a single task - it substitutes template placeholders with user-defined

A sane and simple Go REST API template.

Gosane πŸ§˜β€β™€οΈ A sane and simple Go REST API template. Clone me and edit me to fit your usecase. What is Gosane? Gosane is a cloneable API template to g

A simple template using Fiber for me to bootstrap API services quickly.

Fiber Template A simple template using Fiber for me to bootstrap API services quickly. Features Fiber GORM air for hot reloading ... and possibly more

This is a simple GoLang script template.

This is a simple GoLang script template.

 Code your next Go web project with (a) Mojito! No matter if its an API or a website, go-mojito assists you with dependency injection, simple routing, custom request / response objects and template rendering
Code your next Go web project with (a) Mojito! No matter if its an API or a website, go-mojito assists you with dependency injection, simple routing, custom request / response objects and template rendering

Go-Mojito is a super-modular library to bootstrap your next Go web project. It can be used for strict API-only purposes as well as server-side renderi

HTML template engine for Go

Ace - HTML template engine for Go Overview Ace is an HTML template engine for Go. This is inspired by Slim and Jade. This is a refinement of Gold. Exa

Package damsel provides html outlining via css-selectors and common template functionality.

Damsel Markup language featuring html outlining via css-selectors, extensible via pkg html/template and others. Library This package expects to exist

A handy, fast and powerful go template engine.
A handy, fast and powerful go template engine.

Hero Hero is a handy, fast and powerful go template engine, which pre-compiles the html templates to go code. It has been used in production environme

Jet template engine

Jet Template Engine for Go Jet is a template engine developed to be easy to use, powerful, dynamic, yet secure and very fast. simple and familiar synt

Releases(v0.1)
Owner
El Donaldo
El Donaldo
Simple system for writing HTML/XML as Go code. Better-performing replacement for html/template and text/template

Simple system for writing HTML as Go code. Use normal Go conditionals, loops and functions. Benefit from typing and code analysis. Better performance than templating. Tiny and dependency-free.

Nelo Mitranim 5 Dec 5, 2022
Api-go-template - A simple Go API template that uses a controller-service based model to build its routes

api-go-template This is a simple Go API template that uses a controller-service

Pedro EspΓ­ndula 1 Feb 18, 2022
starter pack for building backend with go and fiber, with jwt auth

go-fiber-api-template starter pack for building backend with go and fiber, with jwt auth authentication there are few steps for authentication steps:

Yaghoub Zargooshifar 2 Oct 12, 2021
Wrapper package for Go's template/html to allow for easy file-based template inheritance.

Extemplate Extemplate is a small wrapper package around html/template to allow for easy file-based template inheritance. File: templates/parent.tmpl <

Danny van Kooten 51 Dec 6, 2022
Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

quicktemplate A fast, powerful, yet easy to use template engine for Go. Inspired by the Mako templates philosophy. Features Extremely fast. Templates

Aliaksandr Valialkin 2.7k Dec 26, 2022
A template to build dynamic web apps quickly using Go, html/template and javascript

gomodest-template A modest template to build dynamic web apps in Go, HTML and sprinkles and spots of javascript. Why ? Build dynamic websites using th

Adnaan Badr 85 Dec 29, 2022
Made from template temporalio/money-transfer-project-template-go

Temporal Go Project Template This is a simple project for demonstrating Temporal with the Go SDK. The full 20 minute guide is here: https://docs.tempo

MarkGorewicz 0 Jan 6, 2022
Go-project-template - Template for a golang project

This is a template repository for golang project Usage Go to github: https://git

KyberNetwork 4 Oct 25, 2022
Go-api-template - A rough template to give you a starting point for your API

Golang API Template This is only a rough template to give you a starting point f

Only Tunes Radio 3 Jan 14, 2022
Go backend template.

Go Backend Template Examples Database (pgx + goqu): Client Service Transaction User Repository Model (ozzo-validation): User Usecases: Auth User Useca

Pavel Varentsov 30 Nov 26, 2022